errors_test.gno
0.72 Kb · 28 lines
1package bolo
2
3import (
4 "strings"
5 "testing"
6)
7
8// Each error and its copy key, as API §7 pairs them for the registry.
9var errorKeys = map[Error]string{
10 ErrNotUserCall: "err.use_wallet",
11 ErrSessionKey: "err.master_key",
12 ErrNotAdmin: "err.not_allowed",
13 ErrSetting: "err.input",
14}
15
16// TestErrorsLeadWithCopyKeys: every error starts with its own copy key, then ": "
17// and a message (API C10).
18func TestErrorsLeadWithCopyKeys(t *testing.T) {
19 if len(errorKeys) != 4 {
20 t.Errorf("%d errors, API §7 gives the registry 4", len(errorKeys))
21 }
22 for e, want := range errorKeys {
23 key, msg, ok := strings.Cut(string(e), ": ")
24 if !ok || key != want || msg == "" {
25 t.Errorf("%q doesn't start with %s", string(e), want)
26 }
27 }
28}