(t *testing.T)
| 1017 | } |
| 1018 | |
| 1019 | func TestDerivedMetricsView(t *testing.T) { |
| 1020 | // Create source and model |
| 1021 | rt, id := testruntime.NewInstance(t) |
| 1022 | testruntime.PutFiles(t, rt, id, map[string]string{ |
| 1023 | "/data/foo.csv": `a,b,c,d,e |
| 1024 | 1,2,3,4,5 |
| 1025 | 1,2,3,4,5 |
| 1026 | 1,2,3,4,5 |
| 1027 | `, |
| 1028 | "/sources/foo.yaml": ` |
| 1029 | connector: local_file |
| 1030 | path: data/foo.csv |
| 1031 | `, |
| 1032 | "/models/bar.sql": `SELECT * FROM foo`, |
| 1033 | "/metrics/dash.yaml": ` |
| 1034 | version: 1 |
| 1035 | type: metrics_view |
| 1036 | display_name: Dash |
| 1037 | model: bar |
| 1038 | dimensions: |
| 1039 | - column: b |
| 1040 | - column: c |
| 1041 | measures: |
| 1042 | - expression: count(*) |
| 1043 | - expression: avg(a) |
| 1044 | `, |
| 1045 | "/metrics/dash_derived.yaml": ` |
| 1046 | type: metrics_view |
| 1047 | parent: dash |
| 1048 | `, |
| 1049 | }) |
| 1050 | |
| 1051 | _, 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}) |
| 1052 | testruntime.ReconcileParserAndWait(t, rt, id) |
| 1053 | testruntime.RequireReconcileState(t, rt, id, 6, 0, 0) |
| 1054 | testruntime.RequireResource(t, rt, id, metricsRes) |
| 1055 | |
| 1056 | _, metricsRes = newMetricsView("dash_derived", "bar", "dash", []any{"count(*)", runtimev1.Type_CODE_INT64, "avg(a)", runtimev1.Type_CODE_FLOAT64}, []any{"b", runtimev1.Type_CODE_INT64, "c", runtimev1.Type_CODE_INT64}) |
| 1057 | testruntime.ReconcileParserAndWait(t, rt, id) |
| 1058 | testruntime.RequireReconcileState(t, rt, id, 6, 0, 0) |
| 1059 | testruntime.RequireResource(t, rt, id, metricsRes) |
| 1060 | |
| 1061 | // check explore |
| 1062 | _, exploreRes := newExplore("dash_derived", []string{"measure_0", "measure_1"}, []string{"b", "c"}) |
| 1063 | testruntime.ReconcileParserAndWait(t, rt, id) |
| 1064 | testruntime.RequireReconcileState(t, rt, id, 6, 0, 0) |
| 1065 | testruntime.RequireResource(t, rt, id, exploreRes) |
| 1066 | } |
| 1067 | |
| 1068 | func TestStageChanges(t *testing.T) { |
| 1069 | // Create source and model |
nothing calls this directly
no test coverage detected