This repository was archived by the owner on Oct 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathheader_test.go
More file actions
50 lines (46 loc) · 1.41 KB
/
header_test.go
File metadata and controls
50 lines (46 loc) · 1.41 KB
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
package warc
import (
"testing"
)
func TestHeader(t *testing.T) {
h := Header{}
if h.Get("") != "" {
t.Errorf("expected empty string for empty string get")
return
}
h.Set("warc-record-id", "test_id")
if h.Get("WARC-Record-ID") != "test_id" {
t.Errorf("expected get WARC-Record-ID to return %s", "test_id")
return
}
}
func TestCanonicalKey(t *testing.T) {
cases := []struct {
in, expect string
}{
{"warc-record-id", FieldNameWARCRecordID},
{"WARC-DATE", FieldNameWARCDate},
{"Warc-TYPE", FieldNameWARCType},
{"warc-CONCURRENt-to", FieldNameWARCConcurrentTo},
{"warC-block-digest", FieldNameWARCBlockDigest},
{"Warc-payload-Digest", FieldNameWARCPayloadDigest},
{"warc-ip-Address", FieldNameWARCIPAddress},
{"warc-refers-To", FieldNameWARCRefersTo},
{"warc-target-Uri", FieldNameWARCTargetURI},
{"warc-truncated", FieldNameWARCTruncated},
{"warc-warcinfo-Id", FieldNameWARCWarcinfoID},
{"warc-filename", FieldNameWARCFilename},
{"warc-profile", FieldNameWARCProfile},
{"warc-identified-payload-Type", FieldNameWARCIdentifiedPayloadType},
{"warc-segment-Number", FieldNameWARCSegmentNumber},
{"warc-segment-origin-Id", FieldNameWARCSegmentOriginID},
{"warc-segment-total-Length", FieldNameWARCSegmentTotalLength},
}
for i, c := range cases {
got := CanonicalKey(c.in)
if got != c.expect {
t.Errorf("case %d mismatch. expected: '%s', got: '%s'", i, c.expect, got)
continue
}
}
}