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

28 lines
878 B
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"
)
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"},
}
variables, err := BuildProposalVariables(&schema.Transcript{}, entries, 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)
}
}