MCPcopy Index your code
hub / github.com/rilldata/rill / TestCreateTriggerAll

Function TestCreateTriggerAll

runtime/server/controller_test.go:18–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestCreateTriggerAll(t *testing.T) {
19 rt, instanceID := testruntime.NewInstance(t)
20
21 // Create a table directly in the OLAP connector for testing metrics views without any refs.
22 createTableAsSelect(t, rt, instanceID, "duckdb", "foo", "SELECT 'US' AS country")
23
24 // Create test resources
25 testruntime.PutFiles(t, rt, instanceID, map[string]string{
26 // Model
27 "m1.sql": `
28SELECT 'US' AS country
29`,
30 // Metrics view with reference to the model
31 "mv1.yaml": `
32type: metrics_view
33version: 1
34model: m1
35dimensions:
36- column: country
37measures:
38- expression: COUNT(*)
39`,
40 // Explore on mv1
41 "e1.yaml": `
42type: explore
43metrics_view: mv1
44`,
45 // Metrics view on external table without any refs
46 "mv2.yaml": `
47type: metrics_view
48version: 1
49table: foo
50dimensions:
51- column: country
52measures:
53- expression: COUNT(*)
54`,
55 // Explore on mv2
56 "e2.yaml": `
57type: explore
58metrics_view: mv2
59`,
60 })
61 testruntime.ReconcileParserAndWait(t, rt, instanceID)
62 testruntime.RequireReconcileState(t, rt, instanceID, 6, 0, 0)
63
64 // Verify that mv2 has no refs
65 ctrl, err := rt.Controller(context.Background(), instanceID)
66 require.NoError(t, err)
67 r, err := ctrl.Get(context.Background(), &runtimev1.ResourceName{Kind: runtime.ResourceKindMetricsView, Name: "mv2"}, false)
68 require.NoError(t, err)
69 require.Len(t, r.Meta.Refs, 0)
70
71 // Capture version numbers for all resources
72 rs, err := ctrl.List(context.Background(), "", "", false)
73 require.NoError(t, err)
74 versions := make(map[string]int)
75 for _, r := range rs {

Callers

nothing calls this directly

Calls 14

CreateTriggerMethod · 0.95
NewInstanceFunction · 0.92
PutFilesFunction · 0.92
ReconcileParserAndWaitFunction · 0.92
RequireReconcileStateFunction · 0.92
NewNoopFunction · 0.92
NewNoopClientFunction · 0.92
createTableAsSelectFunction · 0.85
testCtxFunction · 0.85
ControllerMethod · 0.80
ListMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected