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

Function TestSourceAndModelNameCollission

runtime/controller_test.go:437–501  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

435}
436
437func TestSourceAndModelNameCollission(t *testing.T) {
438 // Add source for a file
439 rt, id := testruntime.NewInstance(t)
440 testruntime.PutFiles(t, rt, id, map[string]string{
441 "/data/foo.csv": `a,b,c,d,e
4421,2,3,4,5
4431,2,3,4,5
4441,2,3,4,5
445`,
446 "/sources/foo.yaml": `
447connector: local_file
448path: data/foo.csv
449`,
450 })
451 testruntime.ReconcileParserAndWait(t, rt, id)
452 testruntime.RequireReconcileState(t, rt, id, 2, 0, 0)
453 testruntime.RequireOLAPTable(t, rt, id, "foo")
454
455 // Create a source with same name within a different folder
456 testruntime.PutFiles(t, rt, id, map[string]string{
457 "/other_folder/foo.yaml": `
458type: source
459connector: local_file
460path: data/foo.csv
461`,
462 })
463 testruntime.ReconcileParserAndWait(t, rt, id)
464 testruntime.RequireReconcileState(t, rt, id, 2, 1, 1)
465 testruntime.RequireOLAPTable(t, rt, id, "foo")
466
467 // Deleting the other file marks the other as valid
468 testruntime.DeleteFiles(t, rt, id, "/other_folder/foo.yaml")
469 testruntime.ReconcileParserAndWait(t, rt, id)
470 testruntime.RequireReconcileState(t, rt, id, 2, 0, 0)
471 testruntime.RequireOLAPTable(t, rt, id, "foo")
472
473 // Create a source with same name using `name` annotation
474 testruntime.PutFiles(t, rt, id, map[string]string{
475 "/sources/foo_1.yaml": `
476name: foo
477connector: local_file
478path: data/foo.csv
479`,
480 })
481 testruntime.ReconcileParserAndWait(t, rt, id)
482 testruntime.RequireReconcileState(t, rt, id, 2, 1, 1)
483 testruntime.RequireOLAPTable(t, rt, id, "foo")
484
485 // Deleting the other file marks the other as valid
486 testruntime.DeleteFiles(t, rt, id, "/sources/foo_1.yaml")
487 testruntime.ReconcileParserAndWait(t, rt, id)
488 testruntime.RequireReconcileState(t, rt, id, 2, 0, 0)
489 testruntime.RequireOLAPTable(t, rt, id, "foo")
490
491 // Create a model with same name as the source
492 testruntime.PutFiles(t, rt, id, map[string]string{
493 "/models/foo.sql": `SELECT 1`,
494 })

Callers

nothing calls this directly

Calls 7

NewInstanceFunction · 0.92
PutFilesFunction · 0.92
ReconcileParserAndWaitFunction · 0.92
RequireReconcileStateFunction · 0.92
RequireOLAPTableFunction · 0.92
DeleteFilesFunction · 0.92
RequireOLAPTableCountFunction · 0.92

Tested by

no test coverage detected