oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package wire
2
3import (
4 "encoding/json"
5 "reflect"
6 "testing"
7)
8
9// The ability keys, in the spec's order (§3); Base's internal/equipo
10// pins the same list.
11func TestAbilityKeysMatchSpec(t *testing.T) {
12 want := []string{"web", "apps_read", "apps_write", "build", "go_live", "services", "services_add"}
13 if !reflect.DeepEqual(Abilities, want) {
14 t.Errorf("Abilities %v, want %v", Abilities, want)
15 }
16 for _, k := range want {
17 if !KnownAbility(k) {
18 t.Errorf("%s not known", k)
19 }
20 }
21 if KnownAbility("future") || KnownAbility("") {
22 t.Error("an unknown key is known")
23 }
24}
25
26// Base's board keeps only the keys Equipo knows; a key Equipo doesn't
27// know is ignored, and a known key Base left out reads as missing.
28func TestAbilityBoardIgnoresUnknownKeys(t *testing.T) {
29 var b AbilityBoard
30 if err := json.Unmarshal([]byte(`{"revision":7,"admin":true,"ask":"Paul","abilities":{"web":true,"future":false,"build":false}}`), &b); err != nil {
31 t.Fatal(err)
32 }
33 want := AbilityBoard{Revision: 7, Admin: true, Ask: "Paul", Abilities: map[string]bool{"web": true, "build": false}}
34 if !reflect.DeepEqual(b, want) {
35 t.Errorf("board %+v, want %+v", b, want)
36 }
37 if _, ok := b.Abilities["future"]; ok {
38 t.Error("an unknown key was kept")
39 }
40}
41