createUserInbound 辅助:POST /v1/users/{userID}/inbounds,返回 user_inbound 记录 ID。
(t *testing.T, mux *http.ServeMux, userID, inboundID string)
| 55 | |
| 56 | // createUserInbound 辅助:POST /v1/users/{userID}/inbounds,返回 user_inbound 记录 ID。 |
| 57 | func createUserInbound(t *testing.T, mux *http.ServeMux, userID, inboundID string) string { |
| 58 | t.Helper() |
| 59 | body := `{"inbound_id":"` + inboundID + `"}` |
| 60 | rec := httptest.NewRecorder() |
| 61 | req := httptest.NewRequest(http.MethodPost, "/v1/users/"+userID+"/inbounds", bytes.NewReader([]byte(body))) |
| 62 | mux.ServeHTTP(rec, req) |
| 63 | if rec.Code != http.StatusOK { |
| 64 | t.Fatalf("create user inbound status = %d body=%s", rec.Code, rec.Body.String()) |
| 65 | } |
| 66 | var out map[string]any |
| 67 | _ = json.NewDecoder(rec.Body).Decode(&out) |
| 68 | return out["id"].(string) |
| 69 | } |
| 70 | |
| 71 | func TestUserSubscriptionAndApplyFlow(t *testing.T) { |
| 72 | var capturedConfig string |
no test coverage detected