502327678f
praxisItemAction.handle returned a hardcoded per-verb constant on any error, so a Praxis outage, a refused token, a contract mismatch and a decode failure all said the same thing and none of them said "Praxis". The information already existed: praxisClient embeds ecosystemHTTP, so the error is an *ecosystemError with working classifiers, and handle() logged it, traced it and threw it away. servicePraxis joins the two service constants and the failure goes through ecosystemGap, which is what Nexus and Hexis already use. The per-verb string is kept in front of it rather than replaced: it carries which operation did not happen, and the trace is the only other place that exists. No new Russian is added — both halves are lines that already ship. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
55 lines
2.0 KiB
Go
55 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/kami/maven/internal/phraser"
|
|
)
|
|
|
|
// A Praxis lifecycle failure used to return a hardcoded constant that named the
|
|
// verb and never the service, so an outage, a refused token and a contract
|
|
// mismatch all produced the identical sentence (Vikunja #588). The helpers and
|
|
// the Hexis half of the same defect are in ecosystem_gap_test.go.
|
|
|
|
func TestPraxisLifecycle401NamesPraxis(t *testing.T) {
|
|
ctx := context.Background()
|
|
praxis := newFakePraxis(t, fixturePraxisAttentionItems())
|
|
h := newPraxisTestHandler(t, praxis)
|
|
|
|
praxis.SetFault(401)
|
|
reply := h.handlePraxisAct(ctx, praxisItemDec("resolve_item", "item_1"))
|
|
if !strings.Contains(reply, servicePraxis) {
|
|
t.Fatalf("praxis failure does not name Praxis: %q", reply)
|
|
}
|
|
if !strings.Contains(reply, phraser.A(phraser.EcoDenied, serviceVars(servicePraxis))) {
|
|
t.Fatalf("401 from praxis: got %q, want the denied line", reply)
|
|
}
|
|
// The verb that did not happen is still said: the trace is the only other
|
|
// place it exists and he is not reading the trace.
|
|
if !strings.Contains(reply, "не получилось отметить сделанным.") {
|
|
t.Errorf("reply dropped the operation that failed: %q", reply)
|
|
}
|
|
}
|
|
|
|
// TestPraxisLifecycleOutageDiffersFrom401 — the identity that was the bug.
|
|
func TestPraxisLifecycleOutageDiffersFrom401(t *testing.T) {
|
|
ctx := context.Background()
|
|
praxis := newFakePraxis(t, fixturePraxisAttentionItems())
|
|
h := newPraxisTestHandler(t, praxis)
|
|
|
|
praxis.SetFault(401)
|
|
refused := h.handlePraxisAct(ctx, praxisItemDec("acknowledge_item", "item_1"))
|
|
|
|
h.ecosystem = &ecosystemWiring{praxis: newPraxisClient(unreachableURL)}
|
|
outage := h.handlePraxisAct(ctx, praxisItemDec("acknowledge_item", "item_1"))
|
|
|
|
if refused == outage {
|
|
t.Fatalf("a refused token and an outage still say the same thing: %q", refused)
|
|
}
|
|
if !strings.Contains(outage, phraser.A(phraser.EcoDown, serviceVars(servicePraxis))) {
|
|
t.Fatalf("praxis outage: got %q, want the outage line naming Praxis", outage)
|
|
}
|
|
}
|