Skip to content

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rkettelerij committed Oct 1, 2024
1 parent 93b4e20 commit af71dfe
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 10 deletions.
12 changes: 12 additions & 0 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ func Test_newRouter(t *testing.T) {
apiCall: "http://localhost:8181/sitemap.xml",
wantBody: "internal/engine/testdata/expected_sitemap.xml",
},
{
name: "Should have valid structured data of type 'Dataset' on landing page",
configFile: "examples/config_all.yaml",
apiCall: "http://localhost:8181?f=html",
wantBody: "internal/engine/testdata/expected_dataset_landingpage.json",
},
{
name: "Should have valid structured data of type 'Dataset' on (each) collection page",
configFile: "examples/config_all.yaml",
apiCall: "http://localhost:8181/collections/addresses?f=html",
wantBody: "internal/engine/testdata/expected_dataset_collection.json",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
12 changes: 12 additions & 0 deletions internal/engine/testdata/expected_dataset_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": "https://schema.org/",
"@type": "Dataset",
"isPartOf": "http:\/\/localhost:8080?f=html",
"name": "Demo of all OGC specs in one API - Addresses",
"url": "http:\/\/localhost:8080/collections/addresses?f=html","license": "https:\/\/creativecommons.org\/publicdomain\/zero\/1.0\/deed.nl",
"isAccessibleForFree": true,
"creator":{
"@type":"Organization",
"name":"Example Support"
}
}
24 changes: 24 additions & 0 deletions internal/engine/testdata/expected_dataset_landingpage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"@context": "https://schema.org/",
"@type": "Dataset",
"name": "Demo of all OGC specs in one API (OGC API)",
"description": "This is example combines features, 3D and vector tiles in one API. Usually this would encompass one dataset but this demo uses data from various sources. So don\u0027t pay too much attention to the actual data. It\u0027s just an example\/demo of GoKoala\u0027s capabilities.",
"url": "http:\/\/localhost:8080?f=html",
"keywords": ["keyword1, keyword2"],
"license": "https:\/\/creativecommons.org\/publicdomain\/zero\/1.0\/deed.nl",
"isAccessibleForFree": true,
"creator":{
"@type":"Organization",
"name":"Example Support"
},
"hasPart": [
{
"@type": "URL",
"url": "http:\/\/localhost:8080/collections/addresses"
},
{
"@type": "URL",
"url": "http:\/\/localhost:8080/collections/addresses2"
}
]
}
8 changes: 4 additions & 4 deletions internal/ogc/common/core/templates/landing-page.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"keywords": ["{{ .Config.Keywords | join ", " }}"],
{{- end }}
"license": "{{ .Config.License.URL }}",
"isAccessibleForFree": true,
"isAccessibleForFree": true
{{- if .Config.Support }}
"creator":{
,"creator":{
"@type":"Organization",
"name":"{{ .Config.Support.Name }}"
},
"hasPart": [
}
,"hasPart": [
{{- range $index, $coll := .Config.AllCollections.Unique }}
{{- if $index }},{{ end }}
{
Expand Down
12 changes: 6 additions & 6 deletions internal/ogc/common/geospatial/templates/collection.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
"keywords": ["{{ .Params.Metadata.Keywords | join ", " }}"],
{{- end -}}
"license": "{{ .Config.License.URL }}",
"isAccessibleForFree": true,
"isAccessibleForFree": true
{{- if .Config.Support }}
"creator":{
,"creator":{
"@type":"Organization",
"name":"haha {{ .Config.Support.Name }}"
},
"name":"{{ .Config.Support.Name }}"
}
{{- end }}
{{- if and .Params.Metadata .Params.Metadata.Thumbnail }}
"thumbnail": "resources/{{ .Params.Metadata.Thumbnail }}",
,"thumbnail": "resources/{{ .Params.Metadata.Thumbnail }}",
{{- end }}
{{- if and .Params.Metadata .Params.Metadata.LastUpdated }}
"version": "{{ toDate "2006-01-02T15:04:05Z07:00" .Params.Metadata.LastUpdated | date "2006-01-02" }}"
,"version": "{{ toDate "2006-01-02T15:04:05Z07:00" .Params.Metadata.LastUpdated | date "2006-01-02" }}"
{{- end }}
}
</script>
Expand Down

0 comments on commit af71dfe

Please sign in to comment.