(t *testing.T)
| 1066 | } |
| 1067 | |
| 1068 | func 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 |
| 1076 | 1,2,3,4,5 |
| 1077 | 1,2,3,4,5 |
| 1078 | 1,2,3,4,5 |
| 1079 | `, |
| 1080 | "/sources/foo.yaml": ` |
| 1081 | connector: local_file |
| 1082 | path: data/foo.csv |
| 1083 | `, |
| 1084 | "/models/bar.sql": `SELECT * FROM foo`, |
| 1085 | "/metrics/dash.yaml": ` |
| 1086 | version: 1 |
| 1087 | type: metrics_view |
| 1088 | display_name: Dash |
| 1089 | model: bar |
| 1090 | dimensions: |
| 1091 | - column: b |
| 1092 | - column: c |
| 1093 | measures: |
| 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": ` |
| 1108 | connector: local_file |
| 1109 | path: 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 | |
| 1123 | func TestWatch(t *testing.T) { |
| 1124 | // Create instance with watch |
nothing calls this directly
no test coverage detected