1
0
mirror of https://github.com/schollz/croc.git synced 2024-12-26 23:35:48 +03:00

Tests for CatFiles

This commit is contained in:
h3yEllex 2017-10-25 15:01:37 +03:00
parent 7458135202
commit 3bb1c015c8
3 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1 @@
Some simple text to see if it works

View File

@ -0,0 +1 @@
More data to see if it 100% works

View File

@ -81,7 +81,7 @@ func TestCopyFileContents(t *testing.T) {
}
func TestCopyFile(t *testing.T) {
t.Run("Content copied successfully", func(t *testing.T) {
t.Run("Files copied successfully", func(t *testing.T) {
f1 := "testing_data/README.md"
f2 := "testing_data/CopyOfREADME.md"
err := CopyFile(f1, f2)
@ -103,3 +103,17 @@ func TestCopyFile(t *testing.T) {
os.Remove(f2)
})
}
func TestCatFiles(t *testing.T) {
t.Run("CatFiles passing", func(t *testing.T) {
files := []string{"testing_data/catFile1.txt", "testing_data/catFile2.txt"}
err := CatFiles(files, "testing_data/CatFile.txt", false)
if err != nil {
t.Errorf("should pass with no error, got: %v", err)
}
if _, err := os.Stat("testing_data/CatFile.txt"); os.IsNotExist(err) {
t.Errorf("file were not created: %v", err)
}
os.Remove("testing_data/CatFile.txt")
})
}