Skip to content

Commit

Permalink
add TestCleanDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Sep 24, 2024
1 parent ac75e18 commit c4b8787
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions filei_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,24 @@ func TestExistsFile(t *testing.T) {
t.Error("Exists() error data must be false")
}
}

func TestCleanDirectory(t *testing.T) {
directory := "testdata/dir"

defer os.Create(directory + "/data.txt")
defer os.Create(directory + "/item.txt")

dirData, _ := os.ReadDir(directory)

if len(dirData) != 2 {
t.Fatal("CleanDirectory() error data must have 2 files")
}

CleanDirectory(directory)

dirData, _ = os.ReadDir(directory)

if len(dirData) == 2 {
t.Fatal("CleanDirectory() error data must have 0 files")
}
}

0 comments on commit c4b8787

Please # to comment.