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

Function TestTemplateMetricsSQLAPI

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

Source from the content-addressed store, hash-verified

37}
38
39func TestTemplateMetricsSQLAPI(t *testing.T) {
40 rt, instanceID := testruntime.NewInstanceForProject(t, "ad_bids")
41
42 testruntime.RequireParseErrors(t, rt, instanceID, nil)
43
44 api, err := rt.APIForName(context.Background(), instanceID, "templated_mv_sql_api")
45 require.NoError(t, err)
46
47 res, _, err := rt.Resolve(context.Background(), &runtime.ResolveOptions{
48 InstanceID: instanceID,
49 Resolver: api.Spec.Resolver,
50 ResolverProperties: api.Spec.ResolverProperties.AsMap(),
51 Args: map[string]any{"domain": "yahoo.com"},
52 Claims: &runtime.SecurityClaims{},
53 })
54 require.NoError(t, err)
55 defer res.Close()
56
57 require.NotNil(t, res)
58 var rows []map[string]interface{}
59 require.NoError(t, json.Unmarshal(must(res.MarshalJSON()), &rows))
60 require.Equal(t, 1, len(rows))
61 require.Equal(t, 3.0, rows[0]["measure_2"])
62 require.Equal(t, "yahoo.com", rows[0]["domain"])
63 require.Equal(t, "Yahoo", rows[0]["publisher"])
64}
65
66func TestComplexTemplateMetricsSQLAPI(t *testing.T) {
67 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