-
Notifications
You must be signed in to change notification settings - Fork 26
/
geoTrack_test.go
99 lines (76 loc) · 1.73 KB
/
geoTrack_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_geoTrack(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
app.cfg.Blogs = map[string]*configBlog{
"en": {
Lang: "en",
},
"de": {
Lang: "de",
},
}
_ = app.initConfig(false)
// First test (just with track)
gpxBytes, _ := os.ReadFile("testdata/test.gpx")
p := &post{
Blog: "en",
Parameters: map[string][]string{
"gpx": {
string(gpxBytes),
},
},
}
resEn, err := app.getTrack(p)
require.NoError(t, err)
assert.NotEmpty(t, resEn.Paths)
assert.Empty(t, resEn.Points)
assert.Equal(t, "2.70", resEn.Kilometers)
assert.Equal(t, "0:42:53", resEn.Hours)
p.Blog = "de"
resDe, err := app.getTrack(p)
require.NoError(t, err)
assert.NotEmpty(t, resDe.Paths)
assert.Empty(t, resDe.Points)
assert.Equal(t, "2,70", resDe.Kilometers)
assert.Equal(t, "0:42:53", resDe.Hours)
// Second file (with track and waypoint)
gpxBytes, _ = os.ReadFile("testdata/test2.gpx")
p = &post{
Blog: "en",
Parameters: map[string][]string{
"gpx": {
string(gpxBytes),
},
},
}
resEn, err = app.getTrack(p)
require.NoError(t, err)
assert.NotEmpty(t, resEn.Paths)
assert.NotEmpty(t, resEn.Points)
assert.Equal(t, "0.08", resEn.Kilometers)
assert.Equal(t, "0:01:29", resEn.Hours)
// Third file (just with route)
gpxBytes, _ = os.ReadFile("testdata/test3.gpx")
p = &post{
Blog: "en",
Parameters: map[string][]string{
"gpx": {
string(gpxBytes),
},
},
}
resEn, err = app.getTrack(p)
require.NoError(t, err)
assert.NotEmpty(t, resEn.Paths)
assert.Empty(t, resEn.Points)
assert.Equal(t, "", resEn.Kilometers)
assert.Equal(t, "", resEn.Hours)
}