Publish detached sanitized source evidence
This commit is contained in:
@@ -38,3 +38,29 @@ func TestSourceInfoDestinationConversionsAndCopies(t *testing.T) {
|
||||
t.Fatalf("source record destination changed through clone: %q", converted.Destination.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceVersionCheckConversionsAndCopies(t *testing.T) {
|
||||
path := Keys("records").Index(2).Key("version")
|
||||
source := SourceInfo{
|
||||
ID: "source-1",
|
||||
VersionCheck: &SourceVersionCheck{
|
||||
Path: path, Version: Version{Present: true, Text: "123"},
|
||||
Location: &Location{SourceID: "source-1", Line: 4, Column: 8},
|
||||
},
|
||||
}
|
||||
internal := toEngineSourceInfo(source)
|
||||
if internal.VersionCheck == nil || internal.VersionCheck.Path.String() != path.String() ||
|
||||
internal.VersionCheck.Version.Text != "123" || internal.VersionCheck.Location == nil || internal.VersionCheck.Location.Line != 4 {
|
||||
t.Fatalf("engine source version check = %#v", internal.VersionCheck)
|
||||
}
|
||||
converted := fromEngineSourceInfo(internal)
|
||||
copy := cloneSourceInfo(converted)
|
||||
copy.VersionCheck.Path = Keys("changed")
|
||||
copy.VersionCheck.Version.Text = "changed"
|
||||
copy.VersionCheck.Location.Line = 99
|
||||
copy.VersionCheck.Redacted = true
|
||||
if converted.VersionCheck.Path.String() != path.String() || converted.VersionCheck.Version.Text != "123" ||
|
||||
converted.VersionCheck.Location.Line != 4 || converted.VersionCheck.Redacted {
|
||||
t.Fatalf("source version check changed through a detached copy: %#v", converted.VersionCheck)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user