Skip to content

Commit 05feaef

Browse files
committed
PDOK-18065 Atom-Operator - validation unit-tests
1 parent d6b4353 commit 05feaef

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed

api/v3/atom_validation.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ func ValidateAtomWithoutClusterChecks(atom *Atom, warnings *[]string, allErrs *f
8585
var fieldPath *field.Path
8686
if strings.Contains(atom.GetName(), "atom") {
8787
fieldPath = field.NewPath("metadata").Child("name")
88-
smoothoperatorvalidation.AddWarning(warnings, *fieldPath, "should not contain atom", atom.GroupVersionKind(), atom.GetName())
88+
smoothoperatorvalidation.AddWarning(warnings, *fieldPath, "should not contain atom.", atom.GroupVersionKind(), atom.GetName())
8989
}
9090

9191
if atom.ObjectMeta.Labels["pdok.nl/tag"] != "" {
9292
fieldPath = field.NewPath("metadata").Child("labels").Child("pdok.nl/tag")
93-
smoothoperatorvalidation.AddWarning(warnings, *fieldPath, "field is not supposed to be set", atom.GroupVersionKind(), atom.GetName())
93+
smoothoperatorvalidation.AddWarning(warnings, *fieldPath, "field is not supposed to be set.", atom.GroupVersionKind(), atom.GetName())
9494
}
9595

9696
if atom.ObjectMeta.Labels["pdok.nl/dataset-id"] == "" {
@@ -108,6 +108,12 @@ func ValidateAtomWithoutClusterChecks(atom *Atom, warnings *[]string, allErrs *f
108108
smoothoperatorvalidation.AddWarning(warnings, *fieldPath, "label is missing.", atom.GroupVersionKind(), atom.GetName())
109109
}
110110

111+
versionLabel, ok := atom.ObjectMeta.Labels["pdok.nl/service-version"]
112+
if ok && versionLabel != "" {
113+
fieldPath = field.NewPath("metadata").Child("labels").Child("pdok.nl/service-version")
114+
smoothoperatorvalidation.AddWarning(warnings, *fieldPath, "field is not supposed to be set.", atom.GroupVersionKind(), atom.GetName())
115+
}
116+
111117
var feedNames []string
112118
for i, datasetFeed := range atom.Spec.Service.DatasetFeeds {
113119
fieldPath = field.NewPath("spec").Child("service").Child("datasetFeeds").Index(i)

api/v3/atom_validation_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ func TestValidateAtomWithoutClusterChecks(t *testing.T) {
2323
},
2424
{
2525
name: "no-error-atom-name-warning",
26-
expectedWarnings: &[]string{"pdok.nl/v3, Kind=Atom/asis-readonly-prod-atom: metadata.name: should not contain atom"},
26+
expectedWarnings: &[]string{"pdok.nl/v3, Kind=Atom/asis-readonly-prod-atom: metadata.name: should not contain atom."},
2727
expectedErrors: &field.ErrorList{},
2828
},
2929
{
3030
name: "no-error-tag-warning",
31-
expectedWarnings: &[]string{"pdok.nl/v3, Kind=Atom/with-theme-warning: metadata.labels.pdok.nl/tag: field is not supposed to be set"},
31+
expectedWarnings: &[]string{"pdok.nl/v3, Kind=Atom/with-theme-warning: metadata.labels.pdok.nl/tag: field is not supposed to be set."},
3232
expectedErrors: &field.ErrorList{},
3333
},
3434
{
@@ -39,6 +39,11 @@ func TestValidateAtomWithoutClusterChecks(t *testing.T) {
3939
"pdok.nl/v3, Kind=Atom/no-labels-warning: metadata.labels.pdok.nl/service-type: label is missing."},
4040
expectedErrors: &field.ErrorList{},
4141
},
42+
{
43+
name: "no-error-service-version-warning",
44+
expectedWarnings: &[]string{"pdok.nl/v3, Kind=Atom/with-service-version: metadata.labels.pdok.nl/service-version: field is not supposed to be set."},
45+
expectedErrors: &field.ErrorList{},
46+
},
4247
}
4348
for _, tt := range tests {
4449
actualWarnings := []string{}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
apiVersion: pdok.nl/v3
2+
kind: Atom
3+
metadata:
4+
annotations:
5+
kangaroo.pdok.nl/lifecycle-phase: prod
6+
kangaroo.pdok.nl/service-bundle-ids: 65daed5f-e9e4-5791-a7c9-7e9effcca520
7+
kangaroo.pdok.nl/readonly: "true"
8+
labels:
9+
pdok.nl/dataset-id: wetlands
10+
pdok.nl/owner-id: rvo
11+
pdok.nl/service-type: atom
12+
pdok.nl/service-version: v1_0
13+
name: with-service-version
14+
namespace: services
15+
spec:
16+
service:
17+
baseUrl: http://localhost:32788/rvo/wetlands/atom
18+
datasetFeeds:
19+
- author:
20+
21+
name: Ministerie van EL&I - GIS Competence Center
22+
datasetMetadataLinks:
23+
metadataIdentifier: 07d73b60-dfd6-4c54-9c82-9fac70c6c48e
24+
templates:
25+
- csw
26+
- html
27+
entries:
28+
- content:
29+
Wetlands zijn de natte natuurgebieden in Nederland (44 gebieden).
30+
Het Wetland verdrag is op 2 februari 1971 te Ramsar in Iran ondertekend.
31+
Nederland was een van de zestien landen die het Verdrag toen ondertekende.
32+
downloadlinks:
33+
- data: public/rvo/wetlands/65daed5f-e9e4-5791-a7c9-7e9effcca520/3/wetlands.gpkg
34+
polygon:
35+
bbox:
36+
maxx: "7.5553527"
37+
maxy: "55.66948"
38+
minx: "2.354173"
39+
miny: "50.71447"
40+
srs:
41+
name: Amersfoort / RD New
42+
uri: https://www.opengis.net/def/crs/EPSG/0/28992
43+
technicalName: wetlands
44+
title: wetlands
45+
updated: "2025-02-28T09:04:17Z"
46+
spatialDatasetIdentifierCode: 07d73b60-dfd6-4c54-9c82-9fac70c6c48e
47+
spatialDatasetIdentifierNamespace: http://www.pdok.nl
48+
subtitle: wetlands
49+
technicalName: wetlands
50+
title: wetlands
51+
lang: nl
52+
ownerInfoRef: pdok
53+
rights: https://creativecommons.org/publicdomain/zero/1.0/deed.nl
54+
serviceMetadataLinks:
55+
metadataIdentifier: 2751ba40-5100-4186-81be-b7fdee95b49c
56+
templates:
57+
- csw
58+
- opensearch
59+
- html
60+
subtitle: Download Service van wetlands
61+
title: Wetlands

0 commit comments

Comments
 (0)