Download this file
| 1 | package equipo |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "amadan.net/oficina/equipo/internal/equipo/chat" |
| 7 | ) |
| 8 | |
| 9 | // EQUIPO_ABILITIES fixes keys off, or for owners only, for everyone on |
| 10 | // the instance; anything it can't read refuses boot. |
| 11 | func TestAbilitiesConfig(t *testing.T) { |
| 12 | load := func(value string) (Config, error) { |
| 13 | env := map[string]string{"EQUIPO_ORIGIN": "https://equipo.bds.oncarlos.com", "EQUIPO_INSTANCE_KEY": "fixture", "CARLOS_MAIL": "submit", "EQUIPO_ABILITIES": value} |
| 14 | return LoadConfig(func(k string) string { return env[k] }) |
| 15 | } |
| 16 | cfg, err := load("web=off,services_add=owners") |
| 17 | if err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | if cfg.Abilities["web"] != chat.FixedOff || cfg.Abilities["services_add"] != chat.FixedOwners || len(cfg.Abilities) != 2 { |
| 21 | t.Errorf("fixed %v", cfg.Abilities) |
| 22 | } |
| 23 | if cfg, err := load(""); err != nil || len(cfg.Abilities) != 0 { |
| 24 | t.Errorf("unset: %v %v", cfg.Abilities, err) |
| 25 | } |
| 26 | for _, bad := range []string{"weather=off", "web=maybe"} { |
| 27 | if _, err := load(bad); err == nil { |
| 28 | t.Errorf("%q booted", bad) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |