package catalog import ( "regexp" "testing" ) var label = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`) func TestCatalogIDsAreLabels(t *testing.T) { if len(All()) == 0 { t.Fatal("empty catalogue") } for _, e := range All() { if !label.MatchString(e.ID) || len(e.ID) > 20 { t.Errorf("bad id %q", e.ID) } if e.Name == "" || e.Summary == "" || e.Icon == "" { t.Errorf("%s incomplete", e.ID) } } } func TestGet(t *testing.T) { w, ok := Get("welcome") if !ok || !w.Default || w.Tint != "amber" { t.Fatalf("welcome: %+v %v", w, ok) } s, ok := Get("scratchpad") if !ok || s.Default || s.Tint != "rose" { t.Fatalf("scratchpad: %+v %v", s, ok) } c, ok := Get("contra") if !ok || c.Default || c.Tint != "teal" { t.Fatalf("contra: %+v %v", c, ok) } if _, ok := Get("nope"); ok { t.Fatal("unexpected") } }