oficina / base Public

Clone
git clone https://amadan.net/oficina/base

Plain git — no account needed to clone.

Download

Download this file

1package catalog
2
3import (
4 "regexp"
5 "testing"
6)
7
8var label = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`)
9
10func TestCatalogIDsAreLabels(t *testing.T) {
11 if len(All()) == 0 {
12 t.Fatal("empty catalogue")
13 }
14 for _, e := range All() {
15 if !label.MatchString(e.ID) || len(e.ID) > 20 {
16 t.Errorf("bad id %q", e.ID)
17 }
18 if e.Name == "" || e.Summary == "" || e.Icon == "" {
19 t.Errorf("%s incomplete", e.ID)
20 }
21 }
22}
23
24func TestGet(t *testing.T) {
25 w, ok := Get("welcome")
26 if !ok || !w.Default || w.Tint != "amber" {
27 t.Fatalf("welcome: %+v %v", w, ok)
28 }
29 s, ok := Get("scratchpad")
30 if !ok || s.Default || s.Tint != "rose" {
31 t.Fatalf("scratchpad: %+v %v", s, ok)
32 }
33 c, ok := Get("contra")
34 if !ok || c.Default || c.Tint != "teal" {
35 t.Fatalf("contra: %+v %v", c, ok)
36 }
37 if _, ok := Get("nope"); ok {
38 t.Fatal("unexpected")
39 }
40}
41