forked from internetarchive/gowarc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_test.go
More file actions
49 lines (40 loc) · 1.18 KB
/
utils_test.go
File metadata and controls
49 lines (40 loc) · 1.18 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
package warc
import (
"testing"
)
// Tests for the NewRotatorSettings function
func TestNewRotatorSettings(t *testing.T) {
rotatorSettings := NewRotatorSettings()
if rotatorSettings.Prefix != "WARC" {
t.Error("Failed to set WARC rotator's filename prefix")
}
if rotatorSettings.WARCSize != 1000 {
t.Error("Failed to set WARC rotator's WARC size")
}
if rotatorSettings.OutputDirectory != "./" {
t.Error("Failed to set WARC rotator's output directory")
}
if rotatorSettings.Compression != CompressionGzip {
t.Error("Failed to set WARC rotator's compression algorithm")
}
if rotatorSettings.CompressionDictionary != "" {
t.Error("Failed to set WARC rotator's compression dictionary")
}
}
// Tests for the isLineStartingWithHTTPMethod function
func TestIsHTTPRequest(t *testing.T) {
goodHTTPRequestHeaders := []string{
"GET /index.html HTTP/1.1",
"POST /api/login HTTP/1.1",
"DELETE /api/products/456 HTTP/1.1",
"HEAD /about HTTP/1.0",
"OPTIONS / HTTP/1.1",
"PATCH /api/item/789 HTTP/1.1",
"GET /images/logo.png HTTP/1.1",
}
for _, header := range goodHTTPRequestHeaders {
if !isHTTPRequest(header) {
t.Error("Invalid HTTP Method parsing:", header)
}
}
}