Clean up DnD shared prompt asset tests
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -208,6 +209,15 @@ func TestProductionPromptAssetsRegisterAndPrepareDndPrompts(t *testing.T) {
|
|||||||
t.Fatalf("PromptFS().Open(%q) error = %v, want nil", name, err)
|
t.Fatalf("PromptFS().Open(%q) error = %v, want nil", name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, name := range []string{
|
||||||
|
"common-dnd-system.md",
|
||||||
|
"common-dnd-transcript.md",
|
||||||
|
"common-dnd-references.md",
|
||||||
|
} {
|
||||||
|
if _, err := promptFS.Open(name); !errors.Is(err, fs.ErrNotExist) {
|
||||||
|
t.Fatalf("PromptFS().Open(%q) error = %v, want not exist", name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
options, err := registry.ScriptoriumOptions()
|
options, err := registry.ScriptoriumOptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/sharedassets/dnd"
|
|
||||||
"gitea.maximumdirect.net/eric/scriptorium"
|
"gitea.maximumdirect.net/eric/scriptorium"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,49 +50,6 @@ func TestScriptoriumPromptPreparesWithMissingOptionalReferences(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReferencePromptInputRenderingIsDeterministic(t *testing.T) {
|
|
||||||
slot := contracts.ResolvedReferenceSlot{
|
|
||||||
Items: []contracts.ReferenceItem{
|
|
||||||
{
|
|
||||||
SlotName: "roster",
|
|
||||||
MediaType: "text/plain",
|
|
||||||
Content: []byte("second"),
|
|
||||||
Digest: "sha256:bbb",
|
|
||||||
Origin: contracts.ReferenceOrigin{Type: "file", URI: "file:///b.txt"},
|
|
||||||
SizeBytes: 6,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
SlotName: "roster",
|
|
||||||
MediaType: "text/plain",
|
|
||||||
Content: []byte("first"),
|
|
||||||
Digest: "sha256:aaa",
|
|
||||||
Origin: contracts.ReferenceOrigin{Type: "file", URI: "file:///a.txt"},
|
|
||||||
SizeBytes: 5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
first := string(dnd.ReferencePromptInput(slot))
|
|
||||||
second := string(dnd.ReferencePromptInput(slot))
|
|
||||||
if first != second {
|
|
||||||
t.Fatalf("reference rendering was not deterministic:\nfirst=%q\nsecond=%q", first, second)
|
|
||||||
}
|
|
||||||
if !strings.Contains(first, "Reference 1\nOrigin-Type: file\nOrigin-URI: file:///a.txt\nDigest: sha256:aaa") {
|
|
||||||
t.Fatalf("first reference heading was not stable: %q", first)
|
|
||||||
}
|
|
||||||
if strings.Index(first, "first") > strings.Index(first, "second") {
|
|
||||||
t.Fatalf("references were not sorted deterministically: %q", first)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSingleReferencePromptInputKeepsContentOnly(t *testing.T) {
|
|
||||||
got := string(dnd.ReferencePromptInput(contracts.ResolvedReferenceSlot{
|
|
||||||
Items: []contracts.ReferenceItem{{Content: []byte("single reference")}},
|
|
||||||
}))
|
|
||||||
if got != "single reference" {
|
|
||||||
t.Fatalf("single reference rendering = %q, want raw content only", got)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestScriptoriumPromptDiagnosticsOmitRawMaterials(t *testing.T) {
|
func TestScriptoriumPromptDiagnosticsOmitRawMaterials(t *testing.T) {
|
||||||
transcript := []byte(`{"secret":"source text"}`)
|
transcript := []byte(`{"secret":"source text"}`)
|
||||||
reference := "private party note"
|
reference := "private party note"
|
||||||
|
|||||||
Reference in New Issue
Block a user