forked from couchbaselabs/cbgb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zipstatic_test.go
39 lines (36 loc) · 890 Bytes
/
zipstatic_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
package main
import (
"net/http"
"testing"
"time"
)
var parseTimeTests = []struct {
h http.Header
err bool
}{
{http.Header{"Date": {""}}, true},
{http.Header{"Date": {"invalid"}}, true},
{http.Header{"Date": {"1994-11-06T08:49:37Z00:00"}}, true},
{http.Header{"Date": {"Sun, 06 Nov 1994 08:49:37 GMT"}}, false},
{http.Header{"Date": {"Sunday, 06-Nov-94 08:49:37 GMT"}}, false},
{http.Header{"Date": {"Sun Nov 6 08:49:37 1994"}}, false},
}
func TestParseTime(t *testing.T) {
expect := time.Date(1994, 11, 6, 8, 49, 37, 0, time.UTC)
for i, test := range parseTimeTests {
d, err := parseHTTPTime(test.h.Get("Date"))
if err != nil {
if !test.err {
t.Errorf("#%d:\n got err: %v", i, err)
}
continue
}
if test.err {
t.Errorf("#%d:\n should err", i)
continue
}
if !expect.Equal(d) {
t.Errorf("#%d:\n got: %v\nwant: %v", i, d, expect)
}
}
}