package engine import ( "os" "path/filepath" "testing" "yetano.dev/yetano/core/solutions/catalog" ) // The meta-repo's catalog, when this module is checked out inside it. func assetsCatalog(t *testing.T) *catalog.Catalog { t.Helper() dir, _ := filepath.Abs("../../../assets/solutions") if _, err := os.Stat(filepath.Join(dir, "catalog.yaml")); err != nil { t.Skip("assets/solutions not present (module outside the meta-repo)") } c, err := catalog.Load(dir) if err != nil { for _, i := range c.Issues { t.Log(i) } t.Fatal(err) } return c } func TestAssetsCatalog(t *testing.T) { c := assetsCatalog(t) for _, i := range c.Validate() { if i.Severity == "error" { t.Error(i) } else { t.Log(i) } } e := New(c) for _, key := range catalog.SortedIDs(c.Examples) { x := c.Examples[key] in := NewInstance(x.Meta.ID, c.Lookup(x.Spec.Solution), x.Spec.Mode) in.Spec.Parameters = x.Spec.Parameters st, err := e.Evaluate(in, nil) if err != nil { t.Fatalf("%s: %v", key, err) } if !st.Complete { t.Errorf("%s: not complete: %s", key, incompleteText(st)) } for _, m := range st.Messages { t.Logf("%s: %s %s", key, m.Severity, m.Text) } } }