This repository has been archived by the owner on Aug 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
63 lines (56 loc) · 2.63 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"testing"
"time"
)
func Test_checkParameters(t *testing.T) {
var testArgUrl *string
temp := "-gpkgurl https://pdokbrtfaststorage.blob.core.windows.net/testdata/afvalwater.gpkg"
testArgUrl = &temp
var testArgPath *string
temp2 := ""
testArgPath = &temp2
checkParameters(testArgUrl, testArgPath)
temp = ""
temp2 = "-gpkgpath ./test.gpkg"
testArgUrl = &temp
testArgPath = &temp2
checkParameters(testArgUrl, testArgPath)
}
func Test_createTmpFile(t *testing.T) {
testFile := createTmpFile()
if testFile == nil {
t.Error("Could not create temporary file.")
}
}
func Test_downloadGeopackage(t *testing.T) {
testFile := createTmpFile()
if testFile == nil {
t.Error("Could not create temporary file.")
}
downloadGeopackage(testFile, "https://pdokbrtfaststorage.blob.core.windows.net/testdata/afvalwater.gpkg")
}
func Test_generateHTMLForLayer(t *testing.T) {
const expectedResult = "<!-- MapServer Template -->\n<html>\n\t<head>\n\t\t<title>GetFeatureInfo output</title>\n\t</head>\n\t<style type=\"text/css\">table.featureInfo, table.featureInfo td, table.featureInfo th { border: 1px solid #ddd; border-collapse: collapse; margin: 0; padding: 0; font-size: 90%; padding: .2em .1em; } table.featureInfo th { padding: .2em .2em; font-weight: bold; background: #eee; } table.featureInfo td { background: #fff; } table.featureInfo tr.odd td { background: #eee; } table.featureInfo caption { text-align: left; font-size: 100%; font-weight: bold; padding: .2em .2em; }</style>\n\t<body>\n\t\t<table class=\"featureInfo\">\n\t\t\t<caption class=\"featureInfo\">testLayer</caption>\n\t\t\t<tr>\n\t\t\t\t<th>testColumn1</th>\n\t\t\t\t<th>testColumn2</th>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>[testColumn1]</td>\n\t\t\t\t<td>[testColumn2]</td>\n\t\t\t</tr>\n\t\t</table>\n\t</body>\n</html>\n<!-- Generated by PDOK ( https://www.pdok.nl/ ) -->"
testColumn := []string{"testColumn1", "testColumn2", "geom", "shape_len"}
geomColumn := []string{"geo"}
htmlBuffer := generateHTMLForLayer("testLayer", testColumn, geomColumn)
if htmlBuffer == nil {
t.Error("No HTML was generated")
}
if htmlBuffer.String() != expectedResult {
t.Errorf("Result was not OK.\nResult:\n%s.\nExpected:\n%s.", htmlBuffer.String(), expectedResult)
}
}
func Test_checkColumn(t *testing.T) {
badColumns := []string{"geom", "shape_len", "shape_leng", "shape_area", "Shape_Area", "geo"}
geomColumn := []string{"geo"}
for _, badColumn := range badColumns {
if checkColumn(badColumn, geomColumn) {
t.Errorf("%s should not be an valid column name.", badColumn)
}
}
}
func Test_programFinishedSuccesfully(t *testing.T) {
programFinishedSuccesfully(time.Now())
}