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:
parent
7458135202
commit
3bb1c015c8
1
testing_data/catFile1.txt
Normal file
1
testing_data/catFile1.txt
Normal file
@ -0,0 +1 @@
|
||||
Some simple text to see if it works
|
1
testing_data/catFile2.txt
Normal file
1
testing_data/catFile2.txt
Normal file
@ -0,0 +1 @@
|
||||
More data to see if it 100% works
|
@ -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")
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user