Added source and user marks to opportunities type. Any ignored errors are deferred to //nolint with a comment instead of being silently dropped

This commit is contained in:
bwilliams committed 2026-10-13 12:40:11 +01:00
1 parent 6e6dec68c0
commit 9b0e6dccfe
7 files changed
+65 -4

No files matched your search

+1
View File
@@ -144,6 +144,7 @@ func convertOne(release *ocds.Release) *types.Opportunity {
UUIDType: "ocid",
BuyerId: ocdsGetBuyerId(release),
BuyerName: ocdsGetBuyerName(release),
Source: "FindATender",
}
if release.Tender != nil {
+25
View File
@@ -328,3 +328,28 @@ func TestConvertSameDate(t *testing.T) {
t.Fatalf("got %+v, want one opportunity titled %q", got, "second")
}
}
// Every converted opportunity records that it came from Find a Tender,
// whether or not its release has a tender.
func TestConvertSetsSource(t *testing.T) {
const want = "FindATender"
for name, release := range map[string]*ocds.Release{
"with tender": {OCID: "ocds-a", ID: "1", Tender: &ocds.Tender{Title: "A"}},
"nil tender": {OCID: "ocds-b", ID: "1"},
} {
if got := convertOne(release).Source; got != want {
t.Errorf("convertOne (%s): Source = %q, want %q", name, got, want)
}
}
for _, o := range Convert([]ocds.Release{
{OCID: "ocds-a", ID: "1", Tender: &ocds.Tender{Title: "A"}},
{OCID: "ocds-a", ID: "2", Tender: &ocds.Tender{Title: "A amended"}},
{OCID: "ocds-b", ID: "1"},
}) {
if o.Source != want {
t.Errorf("Convert: %s Source = %q, want %q", o.UUID, o.Source, want)
}
}
}