Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Dec 17, 2024
1 parent 61fd5a3 commit c0086fe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (this *Filesystem) PutStream(path string, resource io.Reader, conf ...map[s

// 读取并删除
// read and delete
func (this *Filesystem) ReadAndDelete(path string) (any, error) {
func (this *Filesystem) ReadAndDelete(path string) ([]byte, error) {
path = util.NormalizePath(path)

contents, err := this.Read(path)
Expand Down
46 changes: 46 additions & 0 deletions filesystem/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,3 +468,49 @@ func Test_CreateDir(t *testing.T) {
res33 := fs.Has("/testdir")
assertEqual(res33, false, "Test_CreateDir Delete after Has")
}

func Test_HasDir(t *testing.T) {
assertEqual := assertEqualT(t)

// 根目录
root := "./testdata"
adapter := local_adapter.New(root)

fs := filesystem.New(adapter)

res := fs.Has("/testdir222")
assertEqual(res, true, "Test_HasDir")

res2 := fs.Has("/testdir333")
assertEqual(res2, false, "Test_HasDir 2")
}

func Test_ReadAndDelete(t *testing.T) {
assertEqual := assertEqualT(t)

// 根目录
root := "./testdata"
adapter := local_adapter.New(root)

fs := filesystem.New(adapter)

res, err := fs.Copy("/testcopy.txt", "/testReadAndDelete.txt")
if err != nil {
t.Fatal(err.Error())
}

assertEqual(res, true, "Test_ReadAndDelete")

res2 := fs.Has("/testReadAndDelete.txt")
assertEqual(res2, true, "Test_ReadAndDelete Has")

res3, err := fs.ReadAndDelete("/testReadAndDelete.txt")
if err != nil {
t.Fatal(err.Error())
}

assertEqual(string(res3), "testdata", "Test_ReadAndDelete ReadAndDelete")

res33 := fs.Has("/testReadAndDelete.txt")
assertEqual(res33, false, "Test_ReadAndDelete ReadAndDelete after Has")
}

0 comments on commit c0086fe

Please sign in to comment.