From 7458135202380931f296e396562cd0783211b0fe Mon Sep 17 00:00:00 2001 From: h3yEllex Date: Wed, 25 Oct 2017 14:52:27 +0300 Subject: [PATCH] Test for CopyFile --- utils_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/utils_test.go b/utils_test.go index 9c8a2a65..7b3ba390 100644 --- a/utils_test.go +++ b/utils_test.go @@ -79,3 +79,27 @@ func TestCopyFileContents(t *testing.T) { os.Remove(f2) }) } + +func TestCopyFile(t *testing.T) { + t.Run("Content copied successfully", func(t *testing.T) { + f1 := "testing_data/README.md" + f2 := "testing_data/CopyOfREADME.md" + err := CopyFile(f1, f2) + if err != nil { + t.Errorf("should pass with no error, got: %v", err) + } + f1Length, err := FileSize(f1) + if err != nil { + t.Errorf("can't get file nr1 size: %v", err) + } + f2Length, err := FileSize(f2) + if err != nil { + t.Errorf("can't get file nr2 size: %v", err) + } + + if f1Length != f2Length { + t.Errorf("size of both files should be same got: file1: %d file2: %d", f1Length, f2Length) + } + os.Remove(f2) + }) +}