MCPcopy Index your code
hub / github.com/rilldata/rill / TestDeveloperShopify

Function TestDeveloperShopify

runtime/ai/developer_agent_test.go:13–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestDeveloperShopify(t *testing.T) {
14 // Setup a basic empty project
15 rt, instanceID := testruntime.NewInstanceWithOptions(t, testruntime.InstanceOptions{
16 AIConnector: "openai",
17 Files: map[string]string{
18 "rill.yaml": `
19olap_connector: duckdb
20`,
21 "connectors/duckdb.yaml": `
22type: connector
23driver: duckdb
24`,
25 },
26 })
27 testruntime.RequireReconcileState(t, rt, instanceID, 2, 0, 0)
28
29 // Initialize eval
30 s := newEval(t, rt, instanceID)
31
32 // Ask it to add a Shopify dashboard
33 var res *ai.RouterAgentResult
34 _, err := s.CallTool(t.Context(), ai.RoleUser, ai.RouterAgentName, &res, ai.RouterAgentArgs{
35 Prompt: "Develop a dashboard of Shopify orders using mock data. Please proceed without asking clarifying questions.",
36 })
37 require.NoError(t, err)
38 require.Equal(t, ai.DeveloperAgentName, res.Agent)
39
40 // Verify it created a Shopify orders model
41 msg, ok := s.LatestMessage(
42 ai.FilterByTool(ai.DevelopFileName),
43 ai.FilterByType(ai.MessageTypeCall),
44 )
45 require.True(t, ok)
46 args := s.MustUnmarshalMessageContent(msg).(*ai.DevelopFileArgs)
47 require.Contains(t, []string{"explore", "canvas", "metrics_view"}, args.Type)
48
49 // Check that it doesn't have any parse or reconcile errors.
50 testruntime.RequireReconcileState(t, rt, instanceID, -1, 0, 0)
51
52 // Check there's a model and metrics view created related to shopify
53 ctrl, err := rt.Controller(t.Context(), instanceID)
54 require.NoError(t, err)
55 models, err := ctrl.List(t.Context(), runtime.ResourceKindModel, "", false)
56 require.NoError(t, err)
57 metricsViews, err := ctrl.List(t.Context(), runtime.ResourceKindMetricsView, "", false)
58 require.NoError(t, err)
59
60 foundModel := false
61 for _, m := range models {
62 if strings.Contains(m.Meta.Name.Name, "shopify") {
63 foundModel = true
64 break
65 }
66 }
67 require.True(t, foundModel, "expected a model related to shopify")
68
69 foundMV := false
70 for _, mv := range metricsViews {

Callers

nothing calls this directly

Calls 12

NewInstanceWithOptionsFunction · 0.92
RequireReconcileStateFunction · 0.92
FilterByToolFunction · 0.92
FilterByTypeFunction · 0.92
newEvalFunction · 0.85
CallToolMethod · 0.80
LatestMessageMethod · 0.80
ContainsMethod · 0.80
ControllerMethod · 0.80
ListMethod · 0.80
ContextMethod · 0.65

Tested by

no test coverage detected