forked from ceph/go-ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserperm_test.go
43 lines (39 loc) · 1.03 KB
/
userperm_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
43
package cephfs
import (
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
func TestUserPerm(t *testing.T) {
t.Run("newAndDestroy", func(t *testing.T) {
uperm := NewUserPerm(0, 0, nil)
assert.NotNil(t, uperm)
assert.Equal(t, 0, len(uperm.gidList))
assert.True(t, uperm.managed)
// Destroy should be idempotent in our go library
uperm.Destroy()
uperm.Destroy()
})
t.Run("notManagedDestroy", func(t *testing.T) {
uperm := &UserPerm{}
assert.False(t, uperm.managed)
// Calling destroy shouldn't do much but is safe to call (many times)
uperm.Destroy()
uperm.Destroy()
})
t.Run("tryForceGc", func(t *testing.T) {
func() {
uperm := NewUserPerm(0, 0, nil)
_ = uperm
}()
runtime.GC()
})
t.Run("gidList", func(t *testing.T) {
uperm := NewUserPerm(1000, 1000, []int{1028, 1192, 2112})
defer uperm.Destroy()
assert.Equal(t, 3, len(uperm.gidList))
assert.EqualValues(t, 1028, uperm.gidList[0])
assert.EqualValues(t, 1192, uperm.gidList[1])
assert.EqualValues(t, 2112, uperm.gidList[2])
})
}