forked from joshuaferrara/go-satellite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spacetrack_test.go
118 lines (116 loc) · 2.31 KB
/
spacetrack_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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package satellite
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("spacetrack tests", func() {
type args struct {
a spacetrackArgs
}
tests := []struct {
name string
args args
want string
}{
{
name: "empty",
want: "//emptyresult/show",
},
{
name: "some stuff",
args: args{
a: spacetrackArgs{
base: "base",
class: "class",
},
},
want: "base/class/emptyresult/show",
},
{
name: "withfilters",
args: args{a: spacetrackArgs{
base: "base",
class: "class",
filters: filters{
{
filterType: "type",
operator: "operator",
value: "value",
},
},
}},
want: "base/class/type/operatorvalue/emptyresult/show",
},
{
name: "multiple filters",
args: args{a: spacetrackArgs{
base: "base",
class: "class",
filters: filters{
{
filterType: "type",
operator: lt,
value: "value",
},
{
filterType: "type2",
operator: "operator2",
value: "value2",
},
},
}},
want: "base/class/type/<value/type2/operator2value2/emptyresult/show",
},
{
name: "order",
args: args{a: spacetrackArgs{
orderByField: "something",
}},
want: "//orderby/something asc/emptyresult/show",
},
{
name: "order specified",
args: args{a: spacetrackArgs{
orderByField: "something",
orderByDir: desc,
}},
want: "//orderby/something desc/emptyresult/show",
},
{
name: "limit",
args: args{a: spacetrackArgs{
limit: 10,
}},
want: "//limit/10/emptyresult/show",
},
{
name: "complete",
args: args{a: spacetrackArgs{
base: baseurl,
class: tle,
orderByField: epoch,
orderByDir: desc,
limit: 1,
filters: filters{{
filterType: noradCatID,
operator: dq,
value: "47966",
}, {
filterType: epoch,
operator: lt,
value: "2021-08-18",
}},
}},
want: "https://www.space-track.org/basicspacedata/query/class/TLE/NORAD_CAT_ID/47966/EPOCH/<2021-08-18/orderby/EPOCH desc/limit/1/emptyresult/show",
},
}
for _, tt := range tests {
tt := tt
Describe(tt.name, func() {
got := buildQuery(tt.args.a)
It("should match expectations", func() {
Expect(got).To(Equal(tt.want))
})
})
}
})