createUser 辅助:POST /v1/users,返回 user ID。
(t *testing.T, mux *http.ServeMux, body string)
| 41 | |
| 42 | // createUser 辅助:POST /v1/users,返回 user ID。 |
| 43 | func createUser(t *testing.T, mux *http.ServeMux, body string) string { |
| 44 | t.Helper() |
| 45 | rec := httptest.NewRecorder() |
| 46 | req := httptest.NewRequest(http.MethodPost, "/v1/users", bytes.NewReader([]byte(body))) |
| 47 | mux.ServeHTTP(rec, req) |
| 48 | if rec.Code != http.StatusOK { |
| 49 | t.Fatalf("create user status = %d body=%s", rec.Code, rec.Body.String()) |
| 50 | } |
| 51 | var out map[string]any |
| 52 | _ = json.NewDecoder(rec.Body).Decode(&out) |
| 53 | return out["id"].(string) |
| 54 | } |
| 55 | |
| 56 | // createUserInbound 辅助:POST /v1/users/{userID}/inbounds,返回 user_inbound 记录 ID。 |
| 57 | func createUserInbound(t *testing.T, mux *http.ServeMux, userID, inboundID string) string { |
no test coverage detected