MCPcopy Create free account
hub / github.com/GetStream/stream-go2 / TestAddUser

Function TestAddUser

users_test.go:38–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestAddUser(t *testing.T) {
39 ctx := context.Background()
40 client, requester := newClient(t)
41 testCases := []struct {
42 object stream.User
43 getOrCreate bool
44 expectedURL string
45 expectedBody string
46 }{
47 {
48 object: stream.User{
49 ID: "user-test",
50 Data: map[string]any{
51 "is_admin": true,
52 "name": "Johnny",
53 },
54 },
55 expectedURL: "https://api.stream-io-api.com/api/v1.0/user/?api_key=key&get_or_create=false",
56 expectedBody: `{"id":"user-test","data":{"is_admin":true,"name":"Johnny"}}`,
57 },
58 {
59 object: stream.User{
60 ID: "user-test",
61 Data: map[string]any{
62 "is_admin": true,
63 "name": "Jane",
64 },
65 },
66 getOrCreate: true,
67 expectedURL: "https://api.stream-io-api.com/api/v1.0/user/?api_key=key&get_or_create=true",
68 expectedBody: `{"id":"user-test","data":{"is_admin":true,"name":"Jane"}}`,
69 },
70 }
71
72 for _, tc := range testCases {
73 _, err := client.Users().Add(ctx, tc.object, tc.getOrCreate)
74 require.NoError(t, err)
75 testRequest(t, requester.req, http.MethodPost, tc.expectedURL, tc.expectedBody)
76 }
77}
78
79func TestUpdateUser(t *testing.T) {
80 ctx := context.Background()

Callers

nothing calls this directly

Calls 4

newClientFunction · 0.85
testRequestFunction · 0.85
UsersMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected