TestResolveTemplatedString is a basic integration test that verifies the RPC delegates to the text resolver. Comprehensive test coverage lives in runtime/resolvers/text_test.go.
(t *testing.T)
| 15 | // TestResolveTemplatedString is a basic integration test that verifies the RPC delegates to the text resolver. |
| 16 | // Comprehensive test coverage lives in runtime/resolvers/text_test.go. |
| 17 | func TestResolveTemplatedString(t *testing.T) { |
| 18 | rt, instanceID := testruntime.NewInstanceWithOptions(t, testruntime.InstanceOptions{ |
| 19 | Files: map[string]string{ |
| 20 | "rill.yaml": "", |
| 21 | "model.sql": ` |
| 22 | SELECT 'US' AS country, 100 AS revenue |
| 23 | UNION ALL |
| 24 | SELECT 'UK' AS country, 200 AS revenue |
| 25 | `, |
| 26 | "mv.yaml": ` |
| 27 | type: metrics_view |
| 28 | version: 1 |
| 29 | model: model |
| 30 | dimensions: |
| 31 | - column: country |
| 32 | measures: |
| 33 | - name: total_revenue |
| 34 | expression: SUM(revenue) |
| 35 | `, |
| 36 | }, |
| 37 | }) |
| 38 | testruntime.RequireReconcileState(t, rt, instanceID, 3, 0, 0) |
| 39 | |
| 40 | srv, err := server.NewServer(t.Context(), &server.Options{}, rt, zap.NewNop(), ratelimit.NewNoop(), activity.NewNoopClient()) |
| 41 | require.NoError(t, err) |
| 42 | |
| 43 | res, err := srv.ResolveTemplatedString(testCtx(), &runtimev1.ResolveTemplatedStringRequest{ |
| 44 | InstanceId: instanceID, |
| 45 | Body: `Revenue: {{ metrics_sql "SELECT total_revenue FROM mv" }}`, |
| 46 | }) |
| 47 | require.NoError(t, err) |
| 48 | require.Equal(t, "Revenue: 300", res.Body) |
| 49 | } |
nothing calls this directly
no test coverage detected