diff --git a/filei_test.go b/filei_test.go index ae0a630..be43fbc 100644 --- a/filei_test.go +++ b/filei_test.go @@ -130,8 +130,8 @@ func TestFiles(t *testing.T) { t.Fatalf("Files() error = %v", err) } - if len(data) != 7 { - t.Fatal("Files() error data must have 7 files") + if len(data) != 8 { + t.Fatal("Files() error data must have 8 files") } } @@ -161,3 +161,17 @@ func TestChmod(t *testing.T) { t.Errorf("Chmod() error data must have a value") } } + +func TestPrepend(t *testing.T) { + filePath := "testdata/pre-app.txt" + + err := Prepend(filePath, "The first line\n") + if err != nil { + t.Errorf("Prepend() error = %v", err) + } + + err = Prepend("wrong path", "The first line\n") + if err == nil { + t.Errorf("Prepend() error data must have a value") + } +} diff --git a/testdata/pre-app.txt b/testdata/pre-app.txt new file mode 100644 index 0000000..1ddd7f2 --- /dev/null +++ b/testdata/pre-app.txt @@ -0,0 +1,3 @@ +The first line +The first line +The first line