(t *testing.T)
| 60 | } |
| 61 | |
| 62 | func TestApiRequest_RawMessage(t *testing.T) { |
| 63 | const payload = `{"id":12345,"count":9999999999}` |
| 64 | s := newTestServerWithMock(t, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 65 | w.WriteHeader(http.StatusOK) |
| 66 | fmt.Fprint(w, payload) |
| 67 | })) |
| 68 | |
| 69 | ctx := context.Background() |
| 70 | resp, err := s.apiRequest(ctx, "/api/test", nil) |
| 71 | require.NoError(t, err) |
| 72 | require.Equal(t, http.StatusOK, resp.Status) |
| 73 | |
| 74 | // Verify raw JSON is preserved. |
| 75 | require.JSONEq(t, payload, string(resp.Body)) |
| 76 | |
| 77 | // Decode into typed struct with int64 fields to verify integers are preserved. |
| 78 | type result struct { |
| 79 | ID int64 `json:"id"` |
| 80 | Count int64 `json:"count"` |
| 81 | } |
| 82 | var r result |
| 83 | err = json.Unmarshal(resp.Body, &r) |
| 84 | require.NoError(t, err) |
| 85 | require.Equal(t, int64(12345), r.ID) |
| 86 | require.Equal(t, int64(9999999999), r.Count) |
| 87 | } |
| 88 | |
| 89 | // testContext returns a context with a test workspace ID. |
| 90 | func testContext() context.Context { |
nothing calls this directly
no test coverage detected