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

Function TestSimpleSQLApi

runtime/resolvers/sql_test.go:93–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestSimpleSQLApi(t *testing.T) {
94 rt, instanceID := testruntime.NewInstanceForProject(t, "ad_bids")
95
96 api, err := rt.APIForName(context.Background(), instanceID, "simple_sql_api")
97 require.NoError(t, err)
98
99 res, _, err := rt.Resolve(context.Background(), &runtime.ResolveOptions{
100 InstanceID: instanceID,
101 Resolver: api.Spec.Resolver,
102 ResolverProperties: api.Spec.ResolverProperties.AsMap(),
103 Args: nil,
104 Claims: &runtime.SecurityClaims{},
105 })
106 require.NoError(t, err)
107 defer res.Close()
108
109 require.NotNil(t, res)
110
111 var rows []map[string]interface{}
112 require.NoError(t, json.Unmarshal(must(res.MarshalJSON()), &rows))
113 require.Equal(t, 5, len(rows))
114 require.Equal(t, 5, len(rows[0]))
115 require.Equal(t, 4.09, rows[0]["bid_price"])
116 require.Equal(t, "msn.com", rows[0]["domain"])
117 require.Equal(t, float64(4000), rows[0]["id"])
118 require.Equal(t, nil, rows[0]["publisher"])
119 require.Equal(t, "2022-03-05T14:49:50.459Z", rows[0]["timestamp"])
120}
121
122func TestTemplateSQLApi(t *testing.T) {
123 rt, instanceID := testruntime.NewInstanceForProject(t, "ad_bids")

Callers

nothing calls this directly

Calls 7

NewInstanceForProjectFunction · 0.92
APIForNameMethod · 0.80
mustFunction · 0.70
ResolveMethod · 0.65
CloseMethod · 0.65
MarshalJSONMethod · 0.65
AsMapMethod · 0.45

Tested by

no test coverage detected