(t *testing.T)
| 36 | } |
| 37 | |
| 38 | func 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 | |
| 79 | func TestUpdateUser(t *testing.T) { |
| 80 | ctx := context.Background() |
nothing calls this directly
no test coverage detected