File: submatches_test.go

package info (click to toggle)
golang-github-jarcoal-httpmock 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 332 kB
  • sloc: makefile: 2
file content (29 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (2)
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
package internal_test

import (
	"net/http"
	"testing"

	"github.com/maxatome/go-testdeep/td"

	"github.com/jarcoal/httpmock/internal"
)

func TestSubmatches(t *testing.T) {
	req, err := http.NewRequest("GET", "/foo/bar", nil)
	td.Require(t).CmpNoError(err)

	var req2 *http.Request

	req2 = internal.SetSubmatches(req, nil)
	td.CmpShallow(t, req2, req)
	td.CmpNil(t, internal.GetSubmatches(req2))

	req2 = internal.SetSubmatches(req, []string{})
	td.Cmp(t, req2, td.Shallow(req))
	td.CmpNil(t, internal.GetSubmatches(req2))

	req2 = internal.SetSubmatches(req, []string{"foo", "123", "-123", "12.3"})
	td.CmpNot(t, req2, td.Shallow(req))
	td.CmpLen(t, internal.GetSubmatches(req2), 4)
}