Files
mesh-host/internal/judge/answer_test.go
T
jschoubben 8717ec76d4 The node-engine follows the module-assignment seat: assignments, not placement; the seat's packages move to mesh-contracts and mesh-delivery (issue 1966)
The state, events and types of the seat mesh-module-assigner say assignments; the legacy node key form is gone from the
reads; the dead seat-verb list of the retired name is deleted. The placement guard and the placed-file sense stay.

Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
2026-11-05 22:08:40 +01:00

26 lines
1.3 KiB
Go

package judge
import (
nodeengine "git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
"github.com/novox/mesh-host/internal/compositions"
"strings"
"testing"
)
// An answer too large for the node's key is fitted: the texts go first, the verdict and the paths stay, and the answer
// given is not changed (moved from mesh-sdk's assignment test with FitAnswer, novox/hq ADR 0593 §7).
func TestFitAnswer(t *testing.T) {
long := strings.Repeat("x", compositions.MaxBody)
big := CandidateAnswer{Proposal: "p-x1", Revision: 1, Verdict: nodeengine.CandidateAnswerVerdictDiffers, Differs: []ModuleDiffers{{
Module: "nats", Why: "differs", Bodies: []ResourceBodies{{ID: "conf", Why: "changed",
Paths: []string{"content.links.1", "content.password"}, Composed: long, Running: long}}}}}
if same := FitAnswer(big, 1<<20); same.Note != "" || same.Differs[0].Bodies[0].Composed != long {
t.Errorf("an answer within the bound was cut: %+v", same.Note)
}
fitted := FitAnswer(big, 4<<10)
if len(fitted.Differs[0].Bodies[0].Composed) != 0 || len(fitted.Differs[0].Bodies[0].Paths) != 2 ||
fitted.Verdict != nodeengine.CandidateAnswerVerdictDiffers || !strings.Contains(fitted.Note, "cut") || big.Differs[0].Bodies[0].Composed == "" {
t.Errorf("fitted as %+v", fitted)
}
}