-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathuser_test.go
55 lines (46 loc) · 1.27 KB
/
user_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
44
45
46
47
48
49
50
51
52
53
54
55
package bolt_test
import (
"context"
"testing"
"github.com/influxdata/platform"
platformtesting "github.com/influxdata/platform/testing"
)
func initUserService(f platformtesting.UserFields, t *testing.T) (platform.UserService, func()) {
c, closeFn, err := NewTestClient()
if err != nil {
t.Fatalf("failed to create new bolt client: %v", err)
}
c.IDGenerator = f.IDGenerator
ctx := context.TODO()
for _, u := range f.Users {
if err := c.PutUser(ctx, u); err != nil {
t.Fatalf("failed to populate users")
}
}
return c, func() {
defer closeFn()
for _, u := range f.Users {
if err := c.DeleteUser(ctx, u.ID); err != nil {
t.Logf("failed to remove users: %v", err)
}
}
}
}
func TestUserService_CreateUser(t *testing.T) {
platformtesting.CreateUser(initUserService, t)
}
func TestUserService_FindUserByID(t *testing.T) {
platformtesting.FindUserByID(initUserService, t)
}
func TestUserService_FindUsers(t *testing.T) {
platformtesting.FindUsers(initUserService, t)
}
func TestUserService_DeleteUser(t *testing.T) {
platformtesting.DeleteUser(initUserService, t)
}
func TestUserService_FindUser(t *testing.T) {
platformtesting.FindUser(initUserService, t)
}
func TestUserService_UpdateUser(t *testing.T) {
platformtesting.UpdateUser(initUserService, t)
}