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

Function TestDerivedMetricsView

runtime/controller_test.go:1019–1066  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1017}
1018
1019func TestDerivedMetricsView(t *testing.T) {
1020 // Create source and model
1021 rt, id := testruntime.NewInstance(t)
1022 testruntime.PutFiles(t, rt, id, map[string]string{
1023 "/data/foo.csv": `a,b,c,d,e
10241,2,3,4,5
10251,2,3,4,5
10261,2,3,4,5
1027`,
1028 "/sources/foo.yaml": `
1029connector: local_file
1030path: data/foo.csv
1031`,
1032 "/models/bar.sql": `SELECT * FROM foo`,
1033 "/metrics/dash.yaml": `
1034version: 1
1035type: metrics_view
1036display_name: Dash
1037model: bar
1038dimensions:
1039- column: b
1040- column: c
1041measures:
1042- expression: count(*)
1043- expression: avg(a)
1044`,
1045 "/metrics/dash_derived.yaml": `
1046type: metrics_view
1047parent: dash
1048`,
1049 })
1050
1051 _, metricsRes := newMetricsView("dash", "bar", "", []any{"count(*)", runtimev1.Type_CODE_INT64, "avg(a)", runtimev1.Type_CODE_FLOAT64}, []any{"b", runtimev1.Type_CODE_INT64, "c", runtimev1.Type_CODE_INT64})
1052 testruntime.ReconcileParserAndWait(t, rt, id)
1053 testruntime.RequireReconcileState(t, rt, id, 6, 0, 0)
1054 testruntime.RequireResource(t, rt, id, metricsRes)
1055
1056 _, metricsRes = newMetricsView("dash_derived", "bar", "dash", []any{"count(*)", runtimev1.Type_CODE_INT64, "avg(a)", runtimev1.Type_CODE_FLOAT64}, []any{"b", runtimev1.Type_CODE_INT64, "c", runtimev1.Type_CODE_INT64})
1057 testruntime.ReconcileParserAndWait(t, rt, id)
1058 testruntime.RequireReconcileState(t, rt, id, 6, 0, 0)
1059 testruntime.RequireResource(t, rt, id, metricsRes)
1060
1061 // check explore
1062 _, exploreRes := newExplore("dash_derived", []string{"measure_0", "measure_1"}, []string{"b", "c"})
1063 testruntime.ReconcileParserAndWait(t, rt, id)
1064 testruntime.RequireReconcileState(t, rt, id, 6, 0, 0)
1065 testruntime.RequireResource(t, rt, id, exploreRes)
1066}
1067
1068func TestStageChanges(t *testing.T) {
1069 // Create source and model

Callers

nothing calls this directly

Calls 7

NewInstanceFunction · 0.92
PutFilesFunction · 0.92
ReconcileParserAndWaitFunction · 0.92
RequireReconcileStateFunction · 0.92
RequireResourceFunction · 0.92
newExploreFunction · 0.85
newMetricsViewFunction · 0.70

Tested by

no test coverage detected