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

Function TestCyclesWithThreeModels

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

Source from the content-addressed store, hash-verified

767}
768
769func TestCyclesWithThreeModels(t *testing.T) {
770 // Create cyclic model
771 rt, id := testruntime.NewInstance(t)
772 testruntime.PutFiles(t, rt, id, map[string]string{
773 "/data/foo.csv": `a,b,c,d,e
7741,2,3,4,5
7751,2,3,4,5
7761,2,3,4,5
777`,
778 "/sources/foo.yaml": `
779connector: local_file
780path: data/foo.csv
781`,
782 "/models/bar1.sql": `SELECT * FROM bar2`,
783 "/models/bar2.sql": `SELECT * FROM bar3`,
784 "/models/bar3.sql": `SELECT * FROM bar1`,
785 })
786 bar1Model, bar1Res := newModel("SELECT * FROM bar2", "bar1", "bar2", 0)
787 bar1Res.Meta.ReconcileError = `dependency`
788 bar1Res.Meta.Refs[0].Kind = runtime.ResourceKindModel
789 bar1Model.State = &runtimev1.ModelState{}
790 bar2Model, bar2Res := newModel("SELECT * FROM bar3", "bar2", "bar3", 0)
791 bar2Res.Meta.ReconcileError = `dependency`
792 bar2Res.Meta.Refs[0].Kind = runtime.ResourceKindModel
793 bar2Model.State = &runtimev1.ModelState{}
794 bar3Model, bar3Res := newModel("SELECT * FROM bar1", "bar3", "bar1", 0)
795 bar3Res.Meta.ReconcileError = `dependency`
796 bar3Res.Meta.Refs[0].Kind = runtime.ResourceKindModel
797 bar3Model.State = &runtimev1.ModelState{}
798 testruntime.ReconcileParserAndWait(t, rt, id)
799 testruntime.RequireReconcileState(t, rt, id, 5, 3, 0)
800 testruntime.RequireResource(t, rt, id, bar1Res)
801 testruntime.RequireResource(t, rt, id, bar2Res)
802 testruntime.RequireResource(t, rt, id, bar3Res)
803
804 testruntime.PutFiles(t, rt, id, map[string]string{
805 "/models/bar1.sql": `SELECT * FROM bar2`,
806 "/models/bar2.sql": `SELECT * FROM bar3`,
807 "/models/bar3.sql": `SELECT * FROM foo`,
808 })
809 _, bar1Res = newModel("SELECT * FROM bar2", "bar1", "bar2", 3)
810 bar1Res.Meta.Refs[0].Kind = runtime.ResourceKindModel
811 _, bar2Res = newModel("SELECT * FROM bar3", "bar2", "bar3", 3)
812 bar2Res.Meta.Refs[0].Kind = runtime.ResourceKindModel
813 _, bar3Res = newModel("SELECT * FROM foo", "bar3", "foo", 3)
814 testruntime.ReconcileParserAndWait(t, rt, id)
815 testruntime.RequireReconcileState(t, rt, id, 5, 0, 0)
816 testruntime.RequireResource(t, rt, id, bar1Res)
817 testruntime.RequireResource(t, rt, id, bar2Res)
818 testruntime.RequireResource(t, rt, id, bar3Res)
819}
820
821func TestMetricsView(t *testing.T) {
822 // Create source and model

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected