MCPcopy Create free account
hub / github.com/rilldata/rill / TestComplexTemplateMetricsSQLAPI

Function TestComplexTemplateMetricsSQLAPI

runtime/resolvers/metrics_sql_test.go:66–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func 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
93func TestPolicyMetricsSQLAPI(t *testing.T) {
94 rt, instanceID := testruntime.NewInstanceForProject(t, "ad_bids")

Callers

nothing calls this directly

Calls 8

NewInstanceForProjectFunction · 0.92
RequireParseErrorsFunction · 0.92
APIForNameMethod · 0.80
mustFunction · 0.70
ResolveMethod · 0.65
CloseMethod · 0.65
MarshalJSONMethod · 0.65
AsMapMethod · 0.45

Tested by

no test coverage detected