Added unit tests, documentation and function descriptions across the board. Increased cyclop complexity threshold to 15 which is a bit more sane than 10 and excluded _test.go files from linters.

This commit is contained in:
bwilliams committed 2026-10-09 18:27:51 +01:00
1 parent 005b335371
commit 7fd321df97
31 files changed
+4106 -1

No files matched your search

+18
View File
@@ -9,12 +9,16 @@ import (
"git.avsdev.uk/Go/job-search/internal/types"
)
// ocdsGetBuyerId returns the buyer's id, or "" if the release has no buyer.
func ocdsGetBuyerId(release *ocds.Release) string {
if release.Buyer != nil {
return string(release.Buyer.ID)
}
return ""
}
// ocdsGetBuyerName returns the buyer's name, or "" if the release has no
// buyer.
func ocdsGetBuyerName(release *ocds.Release) string {
if release.Buyer != nil {
return release.Buyer.Name
@@ -22,6 +26,8 @@ func ocdsGetBuyerName(release *ocds.Release) string {
return ""
}
// ocdsConvertClassification converts an OCDS classification, noting whether
// it is a CPV code.
func ocdsConvertClassification(
classif *ocds.Classification,
) types.ClassificationCode {
@@ -32,6 +38,8 @@ func ocdsConvertClassification(
}
}
// ocdsGetClassifications returns the tender's classification, then each
// item's main and additional classifications, without repeating a code.
func ocdsGetClassifications(release *ocds.Release) []types.ClassificationCode {
classifications := make([]types.ClassificationCode, 0)
if release.Tender == nil {
@@ -62,6 +70,8 @@ func ocdsGetClassifications(release *ocds.Release) []types.ClassificationCode {
return classifications
}
// ocdsIsSMESuitable reports whether any lot of the tender is marked as
// suitable for SMEs. A tender with no lots is not.
func ocdsIsSMESuitable(release *ocds.Release) bool {
if release.Tender == nil {
return false
@@ -78,6 +88,10 @@ func ocdsIsSMESuitable(release *ocds.Release) bool {
}
return false
}
// ocdsIsVCSESuitable reports whether any lot of the tender is marked as
// suitable for VCSEs (voluntary, community and social enterprises). A tender
// with no lots is not.
func ocdsIsVCSESuitable(release *ocds.Release) bool {
if release.Tender == nil {
return false
@@ -95,6 +109,8 @@ func ocdsIsVCSESuitable(release *ocds.Release) bool {
return false
}
// ocdsRelease converts a release's identity, tags and date, and keeps a
// re-encoded copy of the whole release as JSON.
func ocdsRelease(release *ocds.Release) types.OpportunityRelease {
tags := make([]types.OpportunityReleaseTag, 0)
for _, val := range release.Tag {
@@ -120,6 +136,8 @@ func ocdsRelease(release *ocds.Release) types.OpportunityRelease {
return rel
}
// convertOne builds an opportunity from a single release. Convert passes it
// each ocid's latest release, as that has the current state of the tender.
func convertOne(release *ocds.Release) *types.Opportunity {
t := &types.Opportunity{
UUID: release.OCID,