(t *testing.T)
| 1121 | } |
| 1122 | |
| 1123 | func TestWatch(t *testing.T) { |
| 1124 | // Create instance with watch |
| 1125 | // Create source, wait and verify |
| 1126 | // Create model, wait and verify |
| 1127 | // Create metrics view, wait and verify |
| 1128 | // Drop source, wait and verify |
| 1129 | |
| 1130 | rt, id := testruntime.NewInstanceWithOptions(t, testruntime.InstanceOptions{ |
| 1131 | Files: map[string]string{"rill.yaml": ""}, |
| 1132 | WatchRepo: true, |
| 1133 | }) |
| 1134 | |
| 1135 | ctrl, err := rt.Controller(context.Background(), id) |
| 1136 | require.NoError(t, err) |
| 1137 | |
| 1138 | // Since we're using WatchRepo, we can't use testruntime.ReconcileParserAndWait. |
| 1139 | // For now, we'll just add a sleep to give the file watcher time to trigger. |
| 1140 | // NOTE: Refactor to wait for the controller to actually be triggered if we ever have instability |
| 1141 | awaitIdle := func() { |
| 1142 | time.Sleep(2 * time.Second) |
| 1143 | err = ctrl.WaitUntilIdle(context.Background(), true) |
| 1144 | require.NoError(t, err) |
| 1145 | } |
| 1146 | |
| 1147 | // Make sure there's time for the watcher to start |
| 1148 | awaitIdle() |
| 1149 | |
| 1150 | testruntime.PutFiles(t, rt, id, map[string]string{ |
| 1151 | "/data/foo.csv": `a,b,c,d,e |
| 1152 | 1,2,3,4,5 |
| 1153 | 1,2,3,4,5 |
| 1154 | 1,2,3,4,5 |
| 1155 | `, |
| 1156 | "/sources/foo.yaml": ` |
| 1157 | connector: local_file |
| 1158 | path: data/foo.csv |
| 1159 | `, |
| 1160 | }) |
| 1161 | awaitIdle() |
| 1162 | testruntime.RequireReconcileState(t, rt, id, 2, 0, 0) |
| 1163 | testruntime.RequireOLAPTable(t, rt, id, "foo") |
| 1164 | _, sourceRes := newSource("foo", "data/foo.csv", localFileHash(t, rt, id, []string{"data/foo.csv"}), 3) |
| 1165 | testruntime.RequireResource(t, rt, id, sourceRes) |
| 1166 | |
| 1167 | testruntime.PutFiles(t, rt, id, map[string]string{ |
| 1168 | "/models/bar.sql": `SELECT * FROM foo`, |
| 1169 | }) |
| 1170 | awaitIdle() |
| 1171 | testruntime.RequireReconcileState(t, rt, id, 3, 0, 0) |
| 1172 | testruntime.RequireOLAPTable(t, rt, id, "bar") |
| 1173 | _, modelRes := newModel("SELECT * FROM foo", "bar", "foo", 3) |
| 1174 | testruntime.RequireResource(t, rt, id, modelRes) |
| 1175 | |
| 1176 | testruntime.PutFiles(t, rt, id, map[string]string{ |
| 1177 | "/metrics/dash.yaml": ` |
| 1178 | version: 1 |
| 1179 | type: metrics_view |
| 1180 | display_name: Dash |
nothing calls this directly
no test coverage detected