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

Function TestCyclesWithTwoModels

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

Source from the content-addressed store, hash-verified

720}
721
722func TestCyclesWithTwoModels(t *testing.T) {
723 // Create cyclic model
724 rt, id := testruntime.NewInstance(t)
725 testruntime.PutFiles(t, rt, id, map[string]string{
726 "/models/bar1.sql": `SELECT * FROM bar2`,
727 "/models/bar2.sql": `SELECT * FROM bar1`,
728 })
729 bar1Model, bar1Res := newModel("SELECT * FROM bar2", "bar1", "bar2", 0)
730 bar1Res.Meta.ReconcileError = `dependency`
731 bar1Res.Meta.Refs[0].Kind = runtime.ResourceKindModel
732 bar1Model.State = &runtimev1.ModelState{}
733 bar2Model, bar2Res := newModel("SELECT * FROM bar1", "bar2", "bar1", 0)
734 bar2Res.Meta.ReconcileError = `dependency`
735 bar2Res.Meta.Refs[0].Kind = runtime.ResourceKindModel
736 bar2Model.State = &runtimev1.ModelState{}
737 testruntime.ReconcileParserAndWait(t, rt, id)
738 testruntime.RequireReconcileState(t, rt, id, 3, 2, 0)
739 testruntime.RequireResource(t, rt, id, bar1Res)
740 testruntime.RequireResource(t, rt, id, bar2Res)
741
742 testruntime.DeleteFiles(t, rt, id, "/models/bar1.sql")
743 testruntime.ReconcileParserAndWait(t, rt, id)
744 testruntime.RequireReconcileState(t, rt, id, 2, 1, 0)
745 bar2Res.Meta.ReconcileError = `Catalog Error: Table with name bar1 does not exist!`
746 bar2Res.Meta.Refs = []*runtimev1.ResourceName{}
747 testruntime.RequireResource(t, rt, id, bar2Res)
748}
749
750func TestSelfReference(t *testing.T) {
751 rt, id := testruntime.NewInstance(t)

Callers

nothing calls this directly

Calls 7

NewInstanceFunction · 0.92
PutFilesFunction · 0.92
ReconcileParserAndWaitFunction · 0.92
RequireReconcileStateFunction · 0.92
RequireResourceFunction · 0.92
DeleteFilesFunction · 0.92
newModelFunction · 0.85

Tested by

no test coverage detected