(t *testing.T)
| 965 | } |
| 966 | |
| 967 | func TestAPIClient_MetricEndpoints(t *testing.T) { |
| 968 | mock := testutil.NewMockAPI() |
| 969 | defer mock.Close() |
| 970 | client := newTestClient(mock.Server.URL) |
| 971 | |
| 972 | t.Run("get metrics with params", func(t *testing.T) { |
| 973 | mock.Reset() |
| 974 | params := map[string]string{ |
| 975 | "monitor": "abc123", |
| 976 | "field": "duration_p50,success_rate", |
| 977 | "time": "7d", |
| 978 | "env": "production", |
| 979 | "region": "us-east-1", |
| 980 | "withNulls": "true", |
| 981 | } |
| 982 | _, err := client.GET("/metrics", params) |
| 983 | if err != nil { |
| 984 | t.Fatalf("unexpected error: %v", err) |
| 985 | } |
| 986 | req := mock.LastRequest() |
| 987 | if req.Path != "/metrics" { |
| 988 | t.Errorf("expected /metrics, got %s", req.Path) |
| 989 | } |
| 990 | for k, v := range params { |
| 991 | if req.QueryParams.Get(k) != v { |
| 992 | t.Errorf("param %s: expected %q, got %q", k, v, req.QueryParams.Get(k)) |
| 993 | } |
| 994 | } |
| 995 | }) |
| 996 | |
| 997 | t.Run("get aggregates", func(t *testing.T) { |
| 998 | mock.Reset() |
| 999 | _, err := client.GET("/aggregates", map[string]string{"monitor": "abc123"}) |
| 1000 | if err != nil { |
| 1001 | t.Fatalf("unexpected error: %v", err) |
| 1002 | } |
| 1003 | req := mock.LastRequest() |
| 1004 | if req.Path != "/aggregates" { |
| 1005 | t.Errorf("expected /aggregates, got %s", req.Path) |
| 1006 | } |
| 1007 | }) |
| 1008 | } |
| 1009 | |
| 1010 | func TestAPIClient_SiteEndpoints(t *testing.T) { |
| 1011 | mock := testutil.NewMockAPI() |
nothing calls this directly
no test coverage detected