-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_helpers_test.go
More file actions
43 lines (34 loc) · 1020 Bytes
/
test_helpers_test.go
File metadata and controls
43 lines (34 loc) · 1020 Bytes
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
package ddgo
import "testing"
func newTestDetector(tb testing.TB, opts ...Option) *Detector {
tb.Helper()
detector, err := New(opts...)
if err != nil {
tb.Fatalf("New() failed: %v", err)
}
return detector
}
func mustParse(tb testing.TB, detector *Detector, userAgent string) Result {
tb.Helper()
result, err := detector.Parse(userAgent)
if err != nil {
tb.Fatalf("Parse(%q) failed: %v", userAgent, err)
}
return result
}
func mustParseWithHeaders(tb testing.TB, detector *Detector, userAgent string, headers map[string]string) Result {
tb.Helper()
result, err := detector.ParseWithHeaders(userAgent, headers)
if err != nil {
tb.Fatalf("ParseWithHeaders(%q) failed: %v", userAgent, err)
}
return result
}
func mustParseWithHints(tb testing.TB, detector *Detector, userAgent string, hints ClientHints) Result {
tb.Helper()
result, err := detector.ParseWithClientHints(userAgent, hints)
if err != nil {
tb.Fatalf("ParseWithClientHints(%q) failed: %v", userAgent, err)
}
return result
}