(t *testing.T)
| 202 | } |
| 203 | |
| 204 | func TestSource(t *testing.T) { |
| 205 | // Add source |
| 206 | rt, id := testruntime.NewInstance(t) |
| 207 | testruntime.PutFiles(t, rt, id, map[string]string{ |
| 208 | "/data/foo.csv": `a,b,c,d,e |
| 209 | 1,2,3,4,5 |
| 210 | 1,2,3,4,5 |
| 211 | 1,2,3,4,5 |
| 212 | `, |
| 213 | "/sources/foo.yaml": ` |
| 214 | connector: local_file |
| 215 | path: data/foo.csv |
| 216 | `, |
| 217 | }) |
| 218 | testruntime.ReconcileParserAndWait(t, rt, id) |
| 219 | testruntime.RequireReconcileState(t, rt, id, 2, 0, 0) |
| 220 | testruntime.RequireResource(t, rt, id, &runtimev1.Resource{ |
| 221 | Meta: &runtimev1.ResourceMeta{ |
| 222 | Name: &runtimev1.ResourceName{Kind: runtime.ResourceKindModel, Name: "foo"}, |
| 223 | Owner: runtime.GlobalProjectParserName, |
| 224 | FilePaths: []string{"/sources/foo.yaml"}, |
| 225 | }, |
| 226 | Resource: &runtimev1.Resource_Model{ |
| 227 | Model: &runtimev1.Model{ |
| 228 | Spec: &runtimev1.ModelSpec{ |
| 229 | InputConnector: "local_file", |
| 230 | OutputConnector: "duckdb", |
| 231 | InputProperties: testruntime.Must(structpb.NewStruct(map[string]any{"path": "data/foo.csv", "local_files_hash": localFileHash(t, rt, id, []string{"data/foo.csv"})})), |
| 232 | OutputProperties: testruntime.Must(structpb.NewStruct(map[string]any{"materialize": true})), |
| 233 | RefreshSchedule: &runtimev1.Schedule{RefUpdate: true}, |
| 234 | DefinedAsSource: true, |
| 235 | ChangeMode: runtimev1.ModelChangeMode_MODEL_CHANGE_MODE_RESET, |
| 236 | }, |
| 237 | State: &runtimev1.ModelState{ |
| 238 | ExecutorConnector: "duckdb", |
| 239 | ResultConnector: "duckdb", |
| 240 | ResultProperties: testruntime.Must(structpb.NewStruct(map[string]any{"table": "foo", "used_model_name": true, "view": false})), |
| 241 | ResultTable: "foo", |
| 242 | RowsTotal: 3, |
| 243 | }, |
| 244 | }, |
| 245 | }, |
| 246 | }) |
| 247 | testruntime.RequireOLAPTable(t, rt, id, "foo") |
| 248 | testruntime.RequireOLAPTableCount(t, rt, id, "foo", 3) |
| 249 | |
| 250 | // Update underlying data and refresh, verify table is updated |
| 251 | testruntime.PutFiles(t, rt, id, map[string]string{ |
| 252 | "/data/foo.csv": `a,b,c,d,e |
| 253 | 1,2,3,4,5 |
| 254 | `, |
| 255 | }) |
| 256 | testruntime.RefreshAndWait(t, rt, id, &runtimev1.ResourceName{Kind: runtime.ResourceKindModel, Name: "foo"}) |
| 257 | testruntime.RequireReconcileState(t, rt, id, 2, 0, 0) |
| 258 | testruntime.RequireOLAPTable(t, rt, id, "foo") |
| 259 | testruntime.RequireOLAPTableCount(t, rt, id, "foo", 1) |
| 260 | |
| 261 | // Get the model and the ModelManager for its output |
nothing calls this directly
no test coverage detected