package catalogue import ( "strings" "testing" ) // novox/hq ADR 0310 §1, §2: node-reads is a node seat, and its verbs say the commands they replace, so // mesh_search finds them by `cat`, `grep` and `getent passwd` (ADR 0245 §3). func TestNodeReadsIsANodeSeatWhoseVerbsSayWhatTheyReplace(t *testing.T) { s, ok := SeatNamed(ReadsSeat) if !ok { t.Fatalf("the mesh defines no seat %s", ReadsSeat) } if s.Scope != ScopeNode || s.Delivers != "" || !strings.Contains(s.Decision, "0310") { t.Errorf("%s: scope %q, delivers %q, decision %q", ReadsSeat, s.Scope, s.Delivers, s.Decision) } replaced := map[string]string{} for _, v := range s.Serves { if v.Optional { t.Errorf("%s.%s is optional: a new seat's holder serves every verb", ReadsSeat, v.Name) } if len(v.Replaces) == 0 { t.Errorf("%s.%s says nothing it replaces", ReadsSeat, v.Name) } for _, c := range v.Replaces { replaced[c] = v.Name } } for command, verb := range map[string]string{"cat": "read", "grep": "search", "getent passwd": "account", "getent group": "account", "id": "account", "stat": "stat", "readlink": "readlink", "ls": "list"} { if replaced[command] != verb { t.Errorf("%q is replaced by %q, want %s.%s", command, replaced[command], ReadsSeat, verb) } } }