package console import ( "errors" "fmt" "strings" "testing" "github.com/nats-io/nats.go" "github.com/novox/mesh-tools/node-tools/internal/bus" ) // A tool's own error that mentions 503 is the tool's answer, not a routing fault (issue 1529). func TestAToolsOwn503IsNotNothingServes(t *testing.T) { got := whyItFailed("scanner.scan", errors.New("the scanner refused the scan job: 503 Service Unavailable")) if strings.Contains(got, "nothing serves") || !strings.HasPrefix(got, "scanner.scan failed: ") || !strings.Contains(got, "503") { t.Fatalf("got %q", got) } } func TestARealNoRespondersStillSaysNothingServes(t *testing.T) { for _, err := range []error{bus.ErrNoResponders, fmt.Errorf("ask: %w", bus.ErrNoResponders), nats.ErrNoResponders} { if got := whyItFailed("a.b", err); !strings.HasPrefix(got, "nothing serves a.b") { t.Fatalf("%v: got %q", err, got) } } }