(t *testing.T)
| 493 | req := httptest.NewRequest(http.MethodPost, "/api/v1/users", bytes.NewReader(body)) |
| 494 | req.Header.Set("Content-Type", "application/json") |
| 495 | rec := httptest.NewRecorder() |
| 496 | router.ServeHTTP(rec, req) |
| 497 | |
| 498 | if rec.Code != http.StatusCreated { |
| 499 | t.Fatalf("status = %d, want %d: %s", rec.Code, http.StatusCreated, rec.Body.String()) |
| 500 | } |
| 501 | user := store.users["analytics/analyst"] |
| 502 | if user == nil { |
| 503 | t.Fatal("expected user to be created") |
| 504 | } |
| 505 | if user.MaxVCPUs != 8 { |
| 506 | t.Fatalf("MaxVCPUs = %d, want 8", user.MaxVCPUs) |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | func TestCreateUserRejectsNegativeMaxVCPUs(t *testing.T) { |
| 511 | store := newFakeAPIStore() |
| 512 | router := newTestAPIRouter(store) |
| 513 | |
| 514 | body := []byte(`{ |
| 515 | "org_id": "analytics", |
| 516 | "username": "analyst", |
| 517 | "password": "secret", |
| 518 | "max_vcpus": -1 |
| 519 | }`) |
| 520 | req := httptest.NewRequest(http.MethodPost, "/api/v1/users", bytes.NewReader(body)) |
| 521 | req.Header.Set("Content-Type", "application/json") |
| 522 | rec := httptest.NewRecorder() |
| 523 | router.ServeHTTP(rec, req) |
| 524 |
nothing calls this directly
no test coverage detected