-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathusers_test.go
90 lines (71 loc) · 2.15 KB
/
users_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package rockset_test
import (
"fmt"
"strings"
"testing"
"github.com/stretchr/testify/suite"
"github.com/rockset/rockset-go-client"
"github.com/rockset/rockset-go-client/internal/test"
"github.com/rockset/rockset-go-client/option"
)
const CIUser = "[email protected]"
type UserIntegrationSuite struct {
suite.Suite
rc *rockset.RockClient
email string
}
func TestUserIntegration(t *testing.T) {
// we convert the email address to lowercase in Rockset, so must do it here or the test will fail
rc, nameGenerator := vcrTestClient(t, t.Name())
name := strings.ToLower(nameGenerator("test"))
s := UserIntegrationSuite{
rc: rc,
email: fmt.Sprintf("pme+%[email protected]", name),
}
suite.Run(t, &s)
}
func (s *UserIntegrationSuite) TearDownSuite() {
ctx := test.Context()
err := s.rc.DeleteUser(ctx, s.email)
s.Require().NoError(err)
}
func (s *UserIntegrationSuite) TestCreateUser() {
ctx := test.Context()
user, err := s.rc.CreateUser(ctx, s.email, []string{rockset.ReadOnlyRole})
s.Require().NoError(err)
s.Assert().Equal(s.email, user.GetEmail())
}
func (s *UserIntegrationSuite) TestGetCurrentUser() {
ctx := test.Context()
user, err := s.rc.GetCurrentUser(ctx)
s.Require().NoError(err)
s.Assert().Contains([]string{"ACTIVE", "NEW"}, user.GetState())
}
func (s *UserIntegrationSuite) TestGetUser() {
ctx := test.Context()
user, err := s.rc.GetUser(ctx, s.email)
s.Require().NoError(err)
s.Assert().Equal(s.email, user.Email)
s.Assert().Equal("NEW", user.GetState())
}
func (s *UserIntegrationSuite) TestListUsers() {
ctx := test.Context()
users, err := s.rc.ListUsers(ctx)
s.Require().NoError(err)
var found bool
for _, user := range users {
if user.Email == CIUser {
found = true
}
}
s.Assert().True(found)
}
func (s *UserIntegrationSuite) TestUpdateUser() {
ctx := test.Context()
_, err := s.rc.UpdateUser(ctx, s.email, []string{rockset.MemberRole},
option.WithUserFirstName("first"), option.WithUserLastName("last"))
s.Require().NoError(err)
// TODO: can't assert the fist and last name until the user hac accepted
// s.Assert().Equal("first", user.GetFirstName())
// s.Assert().Equal("last", user.GetLastName())
}