Encode checkpoint and debug path identities
This commit is contained in:
@@ -1,13 +1,52 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
func TestCleanDebugPathPreservesRawComponents(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
value string
|
||||
want string
|
||||
}{
|
||||
{value: "", want: "%"},
|
||||
{value: ".", want: "%2E"},
|
||||
{value: "..", want: "%2E%2E"},
|
||||
{value: "a//b", want: "a/%/b"},
|
||||
{value: "/a/", want: "%/a/%"},
|
||||
{value: " a ", want: "%20a%20"},
|
||||
} {
|
||||
if got := cleanDebugPath(test.value); got != test.want {
|
||||
t.Errorf("cleanDebugPath(%q) = %q, want %q", test.value, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebugLLMPathsKeepDotIdentitiesDistinct(t *testing.T) {
|
||||
recorder := newCapturedDebugRecorder()
|
||||
client := WithDebugLLMRecording(attemptDebugLLM{}, recorder)
|
||||
for _, test := range []struct {
|
||||
stageName string
|
||||
path string
|
||||
}{
|
||||
{stageName: ".", path: "%2E/response-0001.json"},
|
||||
{stageName: "..", path: "%2E%2E/response-0002.json"},
|
||||
} {
|
||||
if _, err := client.CompleteStructured(context.Background(), contracts.StructuredCompletionRequest{StageName: test.stageName}, nil); err != nil {
|
||||
t.Fatalf("CompleteStructured(%q): %v", test.stageName, err)
|
||||
}
|
||||
if !recorder.has(test.path) {
|
||||
t.Errorf("debug artifact %q was not written; names = %#v", test.path, recorder.names())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebugSourceDocumentPreservesUnitReferences(t *testing.T) {
|
||||
doc := validSourceDocument()
|
||||
envelope := debugSourceDocumentEnvelope(doc)
|
||||
|
||||
Reference in New Issue
Block a user