Files
audita/internal/framework/proposal_generation/glossary_projection_test.go

33 lines
1.0 KiB
Go

package proposal_generation
import (
"encoding/json"
"testing"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/glossary"
"gitea.maximumdirect.net/eric/audita/v3/internal/core/schema"
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/promptcontext"
)
func TestProposalContextPreservesDistinctEntries(t *testing.T) {
entries := []glossary.Entry{
{Collection: "spells", ID: "shield", Name: "Shield", Category: "spell", Description: "A spell"},
{Collection: "items", ID: "shield", Name: "Shield", Category: "item", Description: "An item"},
}
prepared, err := promptcontext.PrepareGlossaryVariables(entries, nil)
if err != nil {
t.Fatal(err)
}
variables, err := buildProposalVariables(&schema.Transcript{}, prepared, 0, "")
if err != nil {
t.Fatal(err)
}
var decoded []glossary.Entry
if err := json.Unmarshal([]byte(variables["GlossaryJSON"]), &decoded); err != nil {
t.Fatal(err)
}
if len(decoded) != 2 || decoded[0].Category != "spell" || decoded[1].Category != "item" {
t.Fatalf("prompt entries=%+v", decoded)
}
}