(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func TestComplexTemplateMetricsSQLAPI(t *testing.T) { |
| 67 | rt, instanceID := testruntime.NewInstanceForProject(t, "ad_bids") |
| 68 | |
| 69 | testruntime.RequireParseErrors(t, rt, instanceID, nil) |
| 70 | |
| 71 | api, err := rt.APIForName(context.Background(), instanceID, "templated_mv_sql_api_2") |
| 72 | require.NoError(t, err) |
| 73 | |
| 74 | res, _, err := rt.Resolve(context.Background(), &runtime.ResolveOptions{ |
| 75 | InstanceID: instanceID, |
| 76 | Resolver: api.Spec.Resolver, |
| 77 | ResolverProperties: api.Spec.ResolverProperties.AsMap(), |
| 78 | Args: map[string]any{"domain": "yahoo.com", "pageSize": ""}, |
| 79 | Claims: &runtime.SecurityClaims{UserAttributes: map[string]any{"domain": "yahoo.com"}}, |
| 80 | }) |
| 81 | require.NoError(t, err) |
| 82 | defer res.Close() |
| 83 | |
| 84 | require.NotNil(t, res) |
| 85 | var rows []map[string]interface{} |
| 86 | require.NoError(t, json.Unmarshal(must(res.MarshalJSON()), &rows)) |
| 87 | require.Equal(t, 1, len(rows)) |
| 88 | require.Equal(t, 3.0, rows[0]["measure_2"]) |
| 89 | require.Equal(t, "yahoo.com", rows[0]["domain"]) |
| 90 | require.Equal(t, "Yahoo", rows[0]["publisher"]) |
| 91 | } |
| 92 | |
| 93 | func TestPolicyMetricsSQLAPI(t *testing.T) { |
| 94 | rt, instanceID := testruntime.NewInstanceForProject(t, "ad_bids") |
nothing calls this directly
no test coverage detected