(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestCreateTriggerAll(t *testing.T) { |
| 19 | rt, instanceID := testruntime.NewInstance(t) |
| 20 | |
| 21 | // Create a table directly in the OLAP connector for testing metrics views without any refs. |
| 22 | createTableAsSelect(t, rt, instanceID, "duckdb", "foo", "SELECT 'US' AS country") |
| 23 | |
| 24 | // Create test resources |
| 25 | testruntime.PutFiles(t, rt, instanceID, map[string]string{ |
| 26 | // Model |
| 27 | "m1.sql": ` |
| 28 | SELECT 'US' AS country |
| 29 | `, |
| 30 | // Metrics view with reference to the model |
| 31 | "mv1.yaml": ` |
| 32 | type: metrics_view |
| 33 | version: 1 |
| 34 | model: m1 |
| 35 | dimensions: |
| 36 | - column: country |
| 37 | measures: |
| 38 | - expression: COUNT(*) |
| 39 | `, |
| 40 | // Explore on mv1 |
| 41 | "e1.yaml": ` |
| 42 | type: explore |
| 43 | metrics_view: mv1 |
| 44 | `, |
| 45 | // Metrics view on external table without any refs |
| 46 | "mv2.yaml": ` |
| 47 | type: metrics_view |
| 48 | version: 1 |
| 49 | table: foo |
| 50 | dimensions: |
| 51 | - column: country |
| 52 | measures: |
| 53 | - expression: COUNT(*) |
| 54 | `, |
| 55 | // Explore on mv2 |
| 56 | "e2.yaml": ` |
| 57 | type: explore |
| 58 | metrics_view: mv2 |
| 59 | `, |
| 60 | }) |
| 61 | testruntime.ReconcileParserAndWait(t, rt, instanceID) |
| 62 | testruntime.RequireReconcileState(t, rt, instanceID, 6, 0, 0) |
| 63 | |
| 64 | // Verify that mv2 has no refs |
| 65 | ctrl, err := rt.Controller(context.Background(), instanceID) |
| 66 | require.NoError(t, err) |
| 67 | r, err := ctrl.Get(context.Background(), &runtimev1.ResourceName{Kind: runtime.ResourceKindMetricsView, Name: "mv2"}, false) |
| 68 | require.NoError(t, err) |
| 69 | require.Len(t, r.Meta.Refs, 0) |
| 70 | |
| 71 | // Capture version numbers for all resources |
| 72 | rs, err := ctrl.List(context.Background(), "", "", false) |
| 73 | require.NoError(t, err) |
| 74 | versions := make(map[string]int) |
| 75 | for _, r := range rs { |
nothing calls this directly
no test coverage detected