Add canonical source unit provenance
This commit is contained in:
30
internal/framework/pipeline/debug_test.go
Normal file
30
internal/framework/pipeline/debug_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
)
|
||||
|
||||
func TestDebugSourceDocumentPreservesUnitReferences(t *testing.T) {
|
||||
doc := validSourceDocument()
|
||||
envelope := debugSourceDocumentEnvelope(doc)
|
||||
encoded, err := json.Marshal(envelope)
|
||||
if err != nil {
|
||||
t.Fatalf("Marshal(debug source document) error = %v, want nil", err)
|
||||
}
|
||||
|
||||
var decoded debugSourceDocument
|
||||
if err := json.Unmarshal(encoded, &decoded); err != nil {
|
||||
t.Fatalf("Unmarshal(debug source document) error = %v, want nil", err)
|
||||
}
|
||||
if got, want := decoded.Units[0].Ref, (source.SourceRef{SourceID: "source-1", StartUnitID: 1, EndUnitID: 1}); got != want {
|
||||
t.Fatalf("debug source unit ref = %#v, want %#v", got, want)
|
||||
}
|
||||
|
||||
envelope.Units[0].Ref.SourceID = "mutated"
|
||||
if got := doc.Units[0].Ref.SourceID; got != "source-1" {
|
||||
t.Fatalf("source document ref = %q after debug mutation, want source-1", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user