(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestComplete(t *testing.T) { |
| 20 | // Add source, model, and dashboard |
| 21 | rt, id := testruntime.NewInstance(t) |
| 22 | testruntime.PutFiles(t, rt, id, map[string]string{ |
| 23 | "/data/foo.csv": `a,b,c,d,e |
| 24 | 1,2,3,4,5 |
| 25 | 1,2,3,4,5 |
| 26 | 1,2,3,4,5 |
| 27 | `, |
| 28 | "/sources/foo.yaml": ` |
| 29 | connector: local_file |
| 30 | path: data/foo.csv |
| 31 | `, |
| 32 | "/models/bar.sql": ` |
| 33 | SELECT * FROM foo |
| 34 | `, |
| 35 | "/metrics/foobar.yaml": ` |
| 36 | version: 1 |
| 37 | type: metrics_view |
| 38 | model: bar |
| 39 | dimensions: |
| 40 | - name: a |
| 41 | column: a |
| 42 | measures: |
| 43 | - name: b |
| 44 | expression: count(*) |
| 45 | `, |
| 46 | }) |
| 47 | testruntime.ReconcileParserAndWait(t, rt, id) |
| 48 | testruntime.RequireReconcileState(t, rt, id, 4, 0, 0) |
| 49 | |
| 50 | // Verify the source |
| 51 | testruntime.RequireResource(t, rt, id, &runtimev1.Resource{ |
| 52 | Meta: &runtimev1.ResourceMeta{ |
| 53 | Name: &runtimev1.ResourceName{Kind: runtime.ResourceKindModel, Name: "foo"}, |
| 54 | Owner: runtime.GlobalProjectParserName, |
| 55 | FilePaths: []string{"/sources/foo.yaml"}, |
| 56 | }, |
| 57 | Resource: &runtimev1.Resource_Model{ |
| 58 | Model: &runtimev1.Model{ |
| 59 | Spec: &runtimev1.ModelSpec{ |
| 60 | InputConnector: "local_file", |
| 61 | OutputConnector: "duckdb", |
| 62 | InputProperties: testruntime.Must(structpb.NewStruct(map[string]any{"path": "data/foo.csv", "local_files_hash": localFileHash(t, rt, id, []string{"data/foo.csv"})})), |
| 63 | OutputProperties: testruntime.Must(structpb.NewStruct(map[string]any{"materialize": true})), |
| 64 | RefreshSchedule: &runtimev1.Schedule{RefUpdate: true}, |
| 65 | DefinedAsSource: true, |
| 66 | ChangeMode: runtimev1.ModelChangeMode_MODEL_CHANGE_MODE_RESET, |
| 67 | }, |
| 68 | State: &runtimev1.ModelState{ |
| 69 | ExecutorConnector: "duckdb", |
| 70 | ResultConnector: "duckdb", |
| 71 | ResultProperties: testruntime.Must(structpb.NewStruct(map[string]any{"table": "foo", "used_model_name": true, "view": false})), |
| 72 | ResultTable: "foo", |
| 73 | RowsTotal: 3, |
| 74 | }, |
| 75 | }, |
| 76 | }, |
nothing calls this directly
no test coverage detected