55 lines
2.1 KiB
Go
55 lines
2.1 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"), routeCandidate("resolve_item"))
|
|
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"), routeCandidate("acknowledge_item"))
|
|
|
|
h.ecosystem = &ecosystemWiring{praxis: newPraxisClient(unreachableURL)}
|
|
outage := h.handlePraxisAct(ctx, praxisItemDec("acknowledge_item", "item_1"), routeCandidate("acknowledge_item"))
|
|
|
|
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)
|
|
}
|
|
}
|