(t *testing.T)
| 131 | } |
| 132 | |
| 133 | func TestCreateMachineAlreadyExist(t *testing.T) { |
| 134 | ctx := t.Context() |
| 135 | router, _ := NewAPITest(t, ctx) |
| 136 | |
| 137 | body := CreateTestMachine(t, ctx, router, "") |
| 138 | |
| 139 | w := httptest.NewRecorder() |
| 140 | req, err := http.NewRequestWithContext(ctx, http.MethodPost, "/v1/watchers", strings.NewReader(body)) |
| 141 | require.NoError(t, err) |
| 142 | req.Header.Add("User-Agent", UserAgent) |
| 143 | router.ServeHTTP(w, req) |
| 144 | |
| 145 | w = httptest.NewRecorder() |
| 146 | req, err = http.NewRequestWithContext(ctx, http.MethodPost, "/v1/watchers", strings.NewReader(body)) |
| 147 | require.NoError(t, err) |
| 148 | req.Header.Add("User-Agent", UserAgent) |
| 149 | router.ServeHTTP(w, req) |
| 150 | |
| 151 | assert.Equal(t, http.StatusForbidden, w.Code) |
| 152 | assert.JSONEq(t, `{"message":"user 'test': user already exist"}`, w.Body.String()) |
| 153 | } |
| 154 | |
| 155 | func TestAutoRegistration(t *testing.T) { |
| 156 | ctx := t.Context() |
nothing calls this directly
no test coverage detected
searching dependent graphs…