...
1 package internal_test
2
3 import (
4 "net/http"
5 "testing"
6
7 "github.com/maxatome/go-testdeep/td"
8
9 "github.com/jarcoal/httpmock/internal"
10 )
11
12 func TestSubmatches(t *testing.T) {
13 req, err := http.NewRequest("GET", "/foo/bar", nil)
14 td.Require(t).CmpNoError(err)
15
16 var req2 *http.Request
17
18 req2 = internal.SetSubmatches(req, nil)
19 td.CmpShallow(t, req2, req)
20 td.CmpNil(t, internal.GetSubmatches(req2))
21
22 req2 = internal.SetSubmatches(req, []string{})
23 td.Cmp(t, req2, td.Shallow(req))
24 td.CmpNil(t, internal.GetSubmatches(req2))
25
26 req2 = internal.SetSubmatches(req, []string{"foo", "123", "-123", "12.3"})
27 td.CmpNot(t, req2, td.Shallow(req))
28 td.CmpLen(t, internal.GetSubmatches(req2), 4)
29 }
30
View as plain text