45 lines
1.7 KiB
Go
45 lines
1.7 KiB
Go
package console
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// A refusal is said only for the bus's own refusals; a tool's answer that mentions authorization is the
|
|
// tool's answer, not the account's.
|
|
func TestARefusalIsSaidOnlyForTheBussOwn(t *testing.T) {
|
|
for msg, refusal := range map[string]bool{
|
|
`nats: Permissions Violation for Publish to "mesh.mod.x.tool.y"`: true,
|
|
"nats: Authorization Violation": true,
|
|
`claude-code's servers.all.x carries a field "Authorization", which names a credential`: false,
|
|
} {
|
|
got := strings.HasPrefix(whyItFailed("x.y", errors.New(msg)), "this account may not call")
|
|
if got != refusal {
|
|
t.Errorf("%q read as a refusal: %v, want %v", msg, got, refusal)
|
|
}
|
|
}
|
|
}
|
|
|
|
// **A timeout says it is not a failure** (novox/hq issue 265): a push that outlasted the wait had
|
|
// pushed, and the caller read "did not answer in time". No hint names a seat that is gone (novox/hq issue 1126):
|
|
// the grammar's example, the handshake's instructions and a timeout's remedy named the controller's verbs.
|
|
func TestATimeoutIsNotAFailure(t *testing.T) {
|
|
got := whyItFailed("seat:mesh-delivery.deliveries", errors.New("timeout"))
|
|
for _, want := range []string{"not a failure", "may already have done"} {
|
|
if !strings.Contains(got, want) {
|
|
t.Errorf("a seat's timeout does not say %q: %s", want, got)
|
|
}
|
|
}
|
|
for name, text := range map[string]string{
|
|
"grammar": grammar,
|
|
"flat instructions": (&Surface{Flat: true, who: "x"}).instructions(),
|
|
"deep instructions": (&Surface{who: "x"}).instructions(),
|
|
"timeout": got,
|
|
} {
|
|
if strings.Contains(text, "controller") {
|
|
t.Errorf("%s names the controller: %s", name, text)
|
|
}
|
|
}
|
|
}
|