MCPcopy Create free account
hub / github.com/rilldata/rill / TestValidateCartesianColorField

Function TestValidateCartesianColorField

runtime/canvas/component_test.go:171–223  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

169}
170
171func TestValidateCartesianColorField(t *testing.T) {
172 rt, id := testruntime.NewInstanceWithOptions(t, testruntime.InstanceOptions{
173 Files: metricsViewFiles(),
174 })
175
176 // Valid: color as a field config with dimension.
177 testruntime.PutFiles(t, rt, id, map[string]string{
178 "c1.yaml": `
179type: component
180bar_chart:
181 metrics_view: mv1
182 x:
183 field: foo
184 y:
185 field: y
186 color:
187 field: bar
188`})
189 testruntime.ReconcileParserAndWait(t, rt, id)
190 testruntime.RequireReconcileState(t, rt, id, 4, 0, 0)
191
192 // Valid: color as a plain string (should be skipped).
193 testruntime.PutFiles(t, rt, id, map[string]string{
194 "c1.yaml": `
195type: component
196bar_chart:
197 metrics_view: mv1
198 x:
199 field: foo
200 y:
201 field: y
202 color: "primary"
203`})
204 testruntime.ReconcileParserAndWait(t, rt, id)
205 testruntime.RequireReconcileState(t, rt, id, 4, 0, 0)
206
207 // Invalid: color.field is a measure.
208 testruntime.PutFiles(t, rt, id, map[string]string{
209 "c1.yaml": `
210type: component
211bar_chart:
212 metrics_view: mv1
213 x:
214 field: foo
215 y:
216 field: y
217 color:
218 field: y
219`})
220 testruntime.ReconcileParserAndWait(t, rt, id)
221 testruntime.RequireReconcileState(t, rt, id, 4, 1, 0)
222 testruntime.RequireReconcileErrorContains(t, rt, id, runtime.ResourceKindComponent, "c1", "is not a dimension")
223}
224
225func TestValidateCartesianRillMeasures(t *testing.T) {
226 rt, id := testruntime.NewInstanceWithOptions(t, testruntime.InstanceOptions{

Callers

nothing calls this directly

Calls 6

NewInstanceWithOptionsFunction · 0.92
PutFilesFunction · 0.92
ReconcileParserAndWaitFunction · 0.92
RequireReconcileStateFunction · 0.92
metricsViewFilesFunction · 0.85

Tested by

no test coverage detected