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

Function TestStageChanges

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

Source from the content-addressed store, hash-verified

1066}
1067
1068func TestStageChanges(t *testing.T) {
1069 // Create source and model
1070 rt, id := testruntime.NewInstanceWithOptions(t, testruntime.InstanceOptions{
1071 Files: map[string]string{"rill.yaml": ""},
1072 StageChanges: true,
1073 })
1074 testruntime.PutFiles(t, rt, id, map[string]string{
1075 "/data/foo.csv": `a,b,c,d,e
10761,2,3,4,5
10771,2,3,4,5
10781,2,3,4,5
1079`,
1080 "/sources/foo.yaml": `
1081connector: local_file
1082path: data/foo.csv
1083`,
1084 "/models/bar.sql": `SELECT * FROM foo`,
1085 "/metrics/dash.yaml": `
1086version: 1
1087type: metrics_view
1088display_name: Dash
1089model: bar
1090dimensions:
1091- column: b
1092- column: c
1093measures:
1094- expression: count(*)
1095- expression: avg(a)
1096`,
1097 })
1098 _, modelRes := newModel("SELECT * FROM foo", "bar", "foo", 3)
1099 _, 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})
1100 testruntime.ReconcileParserAndWait(t, rt, id)
1101 testruntime.RequireReconcileState(t, rt, id, 4, 0, 0)
1102 testruntime.RequireResource(t, rt, id, modelRes)
1103 testruntime.RequireResource(t, rt, id, metricsRes)
1104
1105 // Invalid source
1106 testruntime.PutFiles(t, rt, id, map[string]string{
1107 "/sources/foo.yaml": `
1108connector: local_file
1109path: data/bar.csv
1110`,
1111 })
1112 testruntime.ReconcileParserAndWait(t, rt, id)
1113 testruntime.RequireReconcileState(t, rt, id, 4, 2, 0)
1114 // model has error but table is retained
1115 modelRes.Meta.ReconcileError = "dependency error"
1116 testruntime.RequireResource(t, rt, id, modelRes)
1117 testruntime.RequireOLAPTable(t, rt, id, "foo")
1118 // metrics has no error
1119 // TODO: is this expected?
1120 testruntime.RequireResource(t, rt, id, metricsRes)
1121}
1122
1123func TestWatch(t *testing.T) {
1124 // Create instance with watch

Callers

nothing calls this directly

Calls 8

NewInstanceWithOptionsFunction · 0.92
PutFilesFunction · 0.92
ReconcileParserAndWaitFunction · 0.92
RequireReconcileStateFunction · 0.92
RequireResourceFunction · 0.92
RequireOLAPTableFunction · 0.92
newModelFunction · 0.85
newMetricsViewFunction · 0.70

Tested by

no test coverage detected