Skip to content

Commit

Permalink
test: additional tests for error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kad-korpem committed Dec 18, 2024
1 parent 2d05b6c commit 3a804c1
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions internal/ogc/tiles/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,66 @@ func TestTiles_Tile(t *testing.T) {
statusCode: http.StatusOK,
},
},
{
name: "request unknown tileMatrixSet",
fields: fields{
configFile: "internal/ogc/tiles/testdata/config_tiles_toplevel.yaml",
url: "http://localhost:8080/tiles/:tileMatrixSetId/:tileMatrix/:tileRow/:tileCol?f=mvt",
tileMatrixSetID: "EuropeanETRS89_LAEAQuad",
tileMatrix: "5",
tileRow: "10",
tileCol: "15",
},
want: want{
body: "unknown tileMatrixSet 'EuropeanETRS89_LAEAQuad'",
statusCode: http.StatusBadRequest,
},
},
{
name: "request tile in unsupported tileMatrix",
fields: fields{
configFile: "internal/ogc/tiles/testdata/config_tiles_toplevel.yaml",
url: "http://localhost:8080/tiles/:tileMatrixSetId/:tileMatrix/:tileRow/:tileCol",
tileMatrixSetID: "NetherlandsRDNewQuad",
tileMatrix: "13",
tileRow: "10",
tileCol: "15.pbf",
},
want: want{
body: "tileMatrix 13 is out of range",
statusCode: http.StatusNotFound,
},
},
{
name: "request tile beyond tileMatrixSetLimits",
fields: fields{
configFile: "internal/ogc/tiles/testdata/config_tiles_toplevel.yaml",
url: "http://localhost:8080/tiles/:tileMatrixSetId/:tileMatrix/:tileRow/:tileCol",
tileMatrixSetID: "NetherlandsRDNewQuad",
tileMatrix: "5",
tileRow: "32",
tileCol: "32.pbf",
},
want: want{
body: "tileRow/tileCol 32/32 is out of range",
statusCode: http.StatusNotFound,
},
},
{
name: "invalid request parameter",
fields: fields{
configFile: "internal/ogc/tiles/testdata/config_tiles_toplevel.yaml",
url: "http://localhost:8080/tiles/:tileMatrixSetId/:tileMatrix/:tileRow/:tileCol",
tileMatrixSetID: "NetherlandsRDNewQuad",
tileMatrix: "5",
tileRow: "3A",
tileCol: "E2.pbf",
},
want: want{
body: "invalid syntax",
statusCode: http.StatusBadRequest,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 3a804c1

Please sign in to comment.