File: util_test.go

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

import (
	"io"
	"net/http"
	"os"
	"testing"

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

func assertBody(t testing.TB, resp *http.Response, expected string) bool {
	t.Helper()

	require := td.Require(t)
	require.NotNil(resp)

	defer resp.Body.Close() //nolint: errcheck

	data, err := io.ReadAll(resp.Body)
	require.CmpNoError(err)

	return td.CmpString(t, data, expected)
}

func writeFile(t testing.TB, file string, content []byte) {
	t.Helper()
	td.Require(t).CmpNoError(os.WriteFile(file, content, 0644))
}