Skip to content

Commit

Permalink
add TestPrepend
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Sep 25, 2024
1 parent 75a174c commit 2dded08
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 16 additions & 2 deletions filei_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -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")
}
}
3 changes: 3 additions & 0 deletions testdata/pre-app.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The first line
The first line
The first line

0 comments on commit 2dded08

Please sign in to comment.