Repository navigation
Expand file tree
/
Copy pathusers_test.go
More file actions
67 lines (56 loc) · 1.53 KB
/
Copy pathusers_test.go
File metadata and controls
67 lines (56 loc) · 1.53 KB
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
package codersdk_test
import (
"encoding/json"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/codersdk"
)
func TestCreateUserRequestJSON(t *testing.T) {
t.Parallel()
marshalTest := func(t *testing.T, req codersdk.CreateUserRequest) {
t.Helper()
data, err := json.Marshal(req)
require.NoError(t, err)
var req2 codersdk.CreateUserRequest
err = json.Unmarshal(data, &req2)
require.NoError(t, err)
require.Equal(t, req, req2)
}
t.Run("MultipleOrganizations", func(t *testing.T) {
t.Parallel()
req := codersdk.CreateUserRequest{
Email: "alice@coder.com",
Username: "alice",
Name: "Alice User",
Password: "",
UserLoginType: codersdk.LoginTypePassword,
OrganizationIDs: []uuid.UUID{uuid.New(), uuid.New()},
}
marshalTest(t, req)
})
t.Run("SingleOrganization", func(t *testing.T) {
t.Parallel()
req := codersdk.CreateUserRequest{
Email: "alice@coder.com",
Username: "alice",
Name: "Alice User",
Password: "",
UserLoginType: codersdk.LoginTypePassword,
OrganizationIDs: []uuid.UUID{uuid.New()},
}
marshalTest(t, req)
})
t.Run("NoOrganization", func(t *testing.T) {
t.Parallel()
req := codersdk.CreateUserRequest{
Email: "alice@coder.com",
Username: "alice",
Name: "Alice User",
Password: "",
UserLoginType: codersdk.LoginTypePassword,
OrganizationIDs: []uuid.UUID{},
}
marshalTest(t, req)
})
}