TestAdminUserCreate tests API /admin/user route (POST)
()
| 229 | |
| 230 | // TestAdminUserCreate tests API /admin/user route (POST) |
| 231 | func (ts *AdminTestSuite) TestAdminUserCreate() { |
| 232 | cases := []struct { |
| 233 | desc string |
| 234 | params map[string]interface{} |
| 235 | expected map[string]interface{} |
| 236 | }{ |
| 237 | { |
| 238 | desc: "Only phone", |
| 239 | params: map[string]interface{}{ |
| 240 | "phone": "123456789", |
| 241 | "password": "test1", |
| 242 | }, |
| 243 | expected: map[string]interface{}{ |
| 244 | "email": "", |
| 245 | "phone": "123456789", |
| 246 | "isAuthenticated": true, |
| 247 | "provider": "phone", |
| 248 | "providers": []string{"phone"}, |
| 249 | "password": "test1", |
| 250 | }, |
| 251 | }, |
| 252 | { |
| 253 | desc: "With password", |
| 254 | params: map[string]interface{}{ |
| 255 | "email": "test1@example.com", |
| 256 | "phone": "123456789", |
| 257 | "password": "test1", |
| 258 | }, |
| 259 | expected: map[string]interface{}{ |
| 260 | "email": "test1@example.com", |
| 261 | "phone": "123456789", |
| 262 | "isAuthenticated": true, |
| 263 | "provider": "email", |
| 264 | "providers": []string{"email", "phone"}, |
| 265 | "password": "test1", |
| 266 | }, |
| 267 | }, |
| 268 | { |
| 269 | desc: "Without password", |
| 270 | params: map[string]interface{}{ |
| 271 | "email": "test2@example.com", |
| 272 | "phone": "", |
| 273 | }, |
| 274 | expected: map[string]interface{}{ |
| 275 | "email": "test2@example.com", |
| 276 | "phone": "", |
| 277 | "isAuthenticated": false, |
| 278 | "provider": "email", |
| 279 | "providers": []string{"email"}, |
| 280 | }, |
| 281 | }, |
| 282 | { |
| 283 | desc: "With empty string password", |
| 284 | params: map[string]interface{}{ |
| 285 | "email": "test3@example.com", |
| 286 | "phone": "", |
| 287 | "password": "", |
| 288 | }, |
nothing calls this directly
no test coverage detected