Migrate framework tests to native producer and artifact contracts

This commit is contained in:
2026-11-22 04:28:48 +00:00
parent 0b46f2d37c
commit 93d94fdd0a
22 changed files with 184 additions and 3309 deletions

View File

@@ -3,34 +3,39 @@ package pipeline
import (
"context"
"testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
)
func TestRunnerUsesProvidedSessionWithoutSourceFallback(t *testing.T) {
for _, test := range []struct {
name string
session string
wantSet bool
want string
}{
{name: "provided", session: " supplied-session ", wantSet: true, want: "supplied-session"},
{name: "empty", wantSet: false},
{name: "provided", session: " supplied-session ", want: "supplied-session"},
{name: "empty"},
} {
t.Run(test.name, func(t *testing.T) {
prepared, _ := preparedTerminalDebugPipeline(t)
output, err := New().Run(context.Background(), RunInput{
prepared := preparedConcurrentPipeline(t, 1)
var session string
calls := 0
installExtractOperation(prepared, 0, func(_ context.Context, request contracts.TypedExtractionRequest[any]) (erasedTypedResult, error) {
calls++
session = request.SessionID
return erasedTypedResult{Value: typedValueForLane(0, request.Chunk.Index)}, nil
})
_, err := New().Run(context.Background(), RunInput{
Prepared: prepared,
RawInput: []byte("input"),
SessionID: test.session,
Workers: 1,
})
if err != nil {
t.Fatal(err)
}
value, found := output.Manifest.Metadata["session_id"]
if found != test.wantSet {
t.Fatalf("manifest session presence = %t, want %t; metadata = %#v", found, test.wantSet, output.Manifest.Metadata)
}
if found && value != test.want {
t.Fatalf("manifest session = %#v, want %q", value, test.want)
if calls != 1 || session != test.want {
t.Fatalf("extract calls=%d session=%q, want one call and %q", calls, session, test.want)
}
})
}