Skip to content

Commit

Permalink
add test for RemoveAll
Browse files Browse the repository at this point in the history
  • Loading branch information
typerat committed Feb 22, 2022
1 parent 25e8a0a commit d6369bb
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions gcsfs/gcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -804,3 +804,35 @@ func TestGcsMkdirAll(t *testing.T) {
}
})
}

func TestGcsRemoveAll(t *testing.T) {
t.Run("non-existent", func(t *testing.T) {
err := gcsAfs.RemoveAll(filepath.Join(bucketName, "a"))
if err != nil {
t.Fatal("failed when removing non-existent file")
}
})
t.Run("success", func(t *testing.T) {
aDir := filepath.Join(bucketName, "a")
bDir := filepath.Join(aDir, "b")

err := gcsAfs.MkdirAll(bDir, 0755)
if err != nil {
t.Fatal(err)
}
_, err = gcsAfs.Stat(bDir)
if err != nil {
t.Fatal(err)
}

err = gcsAfs.RemoveAll(aDir)
if err != nil {
t.Fatalf("failed to remove the folder %s with error: %s", aDir, err)
}

_, err = gcsAfs.Stat(aDir)
if err == nil {
t.Fatalf("folder %s wasn't removed", aDir)
}
})
}

0 comments on commit d6369bb

Please sign in to comment.