mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-29 18:48:24 +00:00
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
17 lines
474 B
Go
17 lines
474 B
Go
package testing
|
|
|
|
import (
|
|
"io"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func ResponseContains(t *testing.T, r *httptest.ResponseRecorder, status int, bodySubstr string) {
|
|
t.Helper()
|
|
body, err := io.ReadAll(r.Result().Body)
|
|
Ok(t, err)
|
|
Assert(t, status == r.Result().StatusCode, "exp %d got %d, body: %s", status, r.Result().StatusCode, string(body))
|
|
Assert(t, strings.Contains(string(body), bodySubstr), "exp %q to be contained in %q", bodySubstr, string(body))
|
|
}
|