forked from colinmarc/hdfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove_test.go
42 lines (30 loc) · 964 Bytes
/
remove_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package hdfs
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRemove(t *testing.T) {
client := getClient(t)
baleet(t, "/_test/todelete")
mkdirp(t, "/_test/todelete")
err := client.Remove("/_test/todelete")
require.NoError(t, err)
fi, err := client.Stat("/_test/todelete")
assert.Nil(t, fi)
assertPathError(t, err, "stat", "/_test/todelete", os.ErrNotExist)
}
func TestRemoveNotExistent(t *testing.T) {
client := getClient(t)
baleet(t, "/_test/nonexistent")
err := client.Remove("/_test/nonexistent")
assertPathError(t, err, "remove", "/_test/nonexistent", os.ErrNotExist)
}
func TestRemoveWithoutPermission(t *testing.T) {
otherClient := getClientForUser(t, "other")
mkdirp(t, "/_test/accessdenied")
touch(t, "/_test/accessdenied/foo")
err := otherClient.Remove("/_test/accessdenied/foo")
assertPathError(t, err, "remove", "/_test/accessdenied/foo", os.ErrPermission)
}