Enforce durable D&D evidence ranges
This commit is contained in:
@@ -168,5 +168,5 @@ func canonicalReferences(refs []source.SourceRef) []source.SourceRef {
|
||||
}
|
||||
|
||||
func validIdentityReference(ref source.SourceRef) bool {
|
||||
return strings.TrimSpace(ref.SourceID) == ref.SourceID && ref.SourceID != "" && ref.StartUnitID > 0 && ref.EndUnitID > 0
|
||||
return strings.TrimSpace(ref.SourceID) == ref.SourceID && ref.SourceID != "" && ref.StartUnitID > 0 && ref.EndUnitID > 0 && ref.StartUnitID <= ref.EndUnitID
|
||||
}
|
||||
|
||||
@@ -75,6 +75,16 @@ func TestDeriveIDRejectsMissingIdentityComponents(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeriveIDRejectsReversedOnlyEvidence(t *testing.T) {
|
||||
if got := DeriveID("The Tavern", []source.SourceRef{{SourceID: "session", StartUnitID: 2, EndUnitID: 1}}); got != "" {
|
||||
t.Fatalf("DeriveID() = %q, want empty ID", got)
|
||||
}
|
||||
valid := source.SourceRef{SourceID: "session", StartUnitID: 3, EndUnitID: 3}
|
||||
if got, want := DeriveID("The Tavern", []source.SourceRef{{SourceID: "session", StartUnitID: 2, EndUnitID: 1}, valid}), DeriveID("The Tavern", []source.SourceRef{valid}); got != want {
|
||||
t.Fatalf("DeriveID() = %q, want %q after filtering reversed evidence", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsValidID(t *testing.T) {
|
||||
valid := DeriveID("The Tavern", []source.SourceRef{{SourceID: "session", StartUnitID: 1, EndUnitID: 1}})
|
||||
if !IsValidID(valid) || !ValidID(valid) {
|
||||
|
||||
Reference in New Issue
Block a user