Complete package for generating ocds structs (with extensions) in golang
This commit is contained in:
1 parent
da726550d4
commit
35974fa070
47 files changed
+9861
-299
No files matched your search
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"releaseSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-schema.json",
|
||||
"releasePackageSchema": "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/release-package-schema.json",
|
||||
"extensions": [
|
||||
"https://standard.open-contracting.org/profiles/eu/latest/en/extension.json",
|
||||
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_amendment_rationale_classifications_extension/master/extension.json",
|
||||
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_budget_breakdown_extension/master/extension.json",
|
||||
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_contract_completion_extension/master/extension.json",
|
||||
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_documentation_extension/master/extension.json",
|
||||
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_pagination_extension/master/extension.json",
|
||||
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_suitability_extension/master/extension.json",
|
||||
"https://raw.githubusercontent.com/portaledcahn/ocds_Links_extension/main/extension.json",
|
||||
"https://raw.githubusercontent.com/cabinetoffice/ocds_uk_extension/main/extension.json",
|
||||
"https://raw.githubusercontent.com/open-contracting-extensions/ocds_performance_failures_extension/master/extension.json"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Package full contains OCDS 1.1 types with the full extension set applied:
|
||||
// the EU profile, UK extension, and the other extensions in extensions.json.
|
||||
package findtender
|
||||
|
||||
//go:generate go run git.avsdev.uk/Go/go-ocds/cmd/ocdsgen generate -c extensions.json -o ocds_gen.go -p findtender
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,46 @@
|
||||
package findtender
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestRoundTrip decodes a release package that uses several extensions and
|
||||
// checks that re-encoding it loses nothing. Numeric IDs are the one expected
|
||||
// change: ID always encodes as a string.
|
||||
func TestRoundTrip(t *testing.T) {
|
||||
in, err := os.ReadFile("testdata/release-package.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var pkg ReleasePackage
|
||||
if err := json.Unmarshal(in, &pkg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
r := pkg.Releases[0]
|
||||
if got := r.Tender.Items[0].ID; got != "1" {
|
||||
t.Errorf("numeric item id: got %q, want \"1\"", got)
|
||||
}
|
||||
if !*r.Tender.Lots[0].Suitability.SME {
|
||||
t.Error("lot suitability lost")
|
||||
}
|
||||
if got := r.Contracts[0].Implementation.PerformanceFailures[0].ID; got != "PF1" {
|
||||
t.Errorf("performance failure: got %q", got)
|
||||
}
|
||||
|
||||
out, err := json.Marshal(pkg)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var want, got any
|
||||
json.Unmarshal(in, &want)
|
||||
json.Unmarshal(out, &got)
|
||||
// Normalise the one numeric ID in the fixture before comparing.
|
||||
want.(map[string]any)["releases"].([]any)[0].(map[string]any)["tender"].(map[string]any)["items"].([]any)[0].(map[string]any)["id"] = "1"
|
||||
if !reflect.DeepEqual(want, got) {
|
||||
t.Fatalf("round trip changed the data:\n%s", out)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"uri": "https://example.com/packages/1.json",
|
||||
"version": "1.1",
|
||||
"publishedDate": "2026-09-01T00:00:00Z",
|
||||
"publisher": {"name": "Example Publisher"},
|
||||
"links": {"next": "https://example.com/packages/2.json"},
|
||||
"releases": [
|
||||
{
|
||||
"ocid": "ocds-abc123-0001",
|
||||
"id": "0001-award",
|
||||
"date": "2026-09-01T09:00:00Z",
|
||||
"tag": ["award", "contract"],
|
||||
"initiationType": "tender",
|
||||
"links": [{"rel": "self", "href": "https://example.com/releases/0001"}],
|
||||
"planning": {
|
||||
"budget": {
|
||||
"id": "B1",
|
||||
"budgetBreakdown": [{"id": "BB1", "amount": {"amount": 1000000, "currency": "EUR"}}]
|
||||
}
|
||||
},
|
||||
"tender": {
|
||||
"id": "T1",
|
||||
"title": "Road maintenance",
|
||||
"lots": [{"id": "L1", "title": "North", "suitability": {"sme": true}}],
|
||||
"items": [{"id": 1, "description": "Resurfacing", "relatedLot": "L1"}],
|
||||
"documents": [{"id": "D1", "relatedLots": ["L1"], "pageStart": "4", "pageEnd": "9"}]
|
||||
},
|
||||
"awards": [{"id": "A1", "relatedLots": ["L1"], "status": "active"}],
|
||||
"contracts": [{
|
||||
"id": "C1",
|
||||
"awardID": "A1",
|
||||
"amendments": [{"id": "AM1", "rationaleClassifications": [{"scheme": "eu-modification-justification", "id": "add-wss"}]}],
|
||||
"implementation": {
|
||||
"endDate": "2027-06-30T00:00:00Z",
|
||||
"finalValue": {"amount": 950000, "currency": "EUR"},
|
||||
"performanceFailures": [{"id": "PF1", "description": "Late delivery"}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user