-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjustlog_api_test.go
112 lines (109 loc) · 1.9 KB
/
justlog_api_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
package justgrep
import (
"testing"
"time"
)
func TestLogsList_Snip(t *testing.T) {
l := LogsList{
AvailableLogEntry{
RawYear: "2022",
RawMonth: "12",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "11",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "10",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "9",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "8",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "7",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "6",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "5",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "4",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "3",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "2",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "1",
},
}
err := l.EnsureParsed()
assert(t, "err", err, nil)
have, err := l.Snip(
time.Date(2022, 4, 1, 0, 0, 0, 0, time.UTC),
time.Date(2022, 10, 1, 0, 0, 0, 0, time.UTC),
)
assert(t, "err", err, nil)
expect := LogsList{
AvailableLogEntry{
RawYear: "2022",
RawMonth: "10",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "9",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "8",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "7",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "6",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "5",
},
AvailableLogEntry{
RawYear: "2022",
RawMonth: "4",
},
}
expect.EnsureParsed()
if len(have) != len(expect) {
t.Errorf(
"assertion on LogsListSnip failed: length doesn't match, have %d, expected %d: %q vs %q",
len(have),
len(expect),
have,
expect,
)
}
for i, elem := range have {
if elem != expect[i] {
t.Errorf("assertion on LogsListSnip[%d] failed: have %#v, expected %#v", i, elem, expect[i])
}
}
}