From 6a725075dba9b19c2f45a3915598c5a28a118873 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Wed, 5 Jul 2023 15:28:13 +0200 Subject: [PATCH 1/2] Add tests for old Go versions Test old Go versions all the way back to 1.17. Signed-off-by: SuperQ --- .github/workflows/main.yml | 20 +++++++++++++++++++- go.mod | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 08e548c07..0ffd24cb3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,9 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go_version: ["1.20", "1.19"] + go_version: + - "1.19" + - "1.20" steps: - uses: actions/checkout@v3 - name: Setup Go @@ -17,3 +19,19 @@ jobs: - run: ./.ci.gofmt.sh - run: ./.ci.govet.sh - run: go test -v -race ./... + test: + runs-on: ubuntu-latest + strategy: + matrix: + go_version: + - "1.17" + - "1.18" + - "1.19" + - "1.20" + steps: + - uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v3.2.0 + with: + go-version: ${{ matrix.go_version }} + - run: go test -v -race ./... diff --git a/go.mod b/go.mod index 60d69a8ea..d3c4d723b 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/stretchr/testify // This should match the minimum supported version that is tested in // .github/workflows/main.yml -go 1.19 +go 1.17 require ( github.com/davecgh/go-spew v1.1.1 From c410dd2f6aa68c48a103cfae39e4a738b84cf8c5 Mon Sep 17 00:00:00 2001 From: Milan Lesichkov Date: Thu, 22 Dec 2022 10:45:24 +0000 Subject: [PATCH 2/2] Fix adding ? when no values passed --- assert/http_assertions.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assert/http_assertions.go b/assert/http_assertions.go index d8038c28a..6cfb6a838 100644 --- a/assert/http_assertions.go +++ b/assert/http_assertions.go @@ -113,7 +113,10 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, va // empty string if building a new request fails. func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { w := httptest.NewRecorder() - req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) + if len(values) > 0 { + url += "?" + values.Encode() + } + req, err := http.NewRequest(method, url, nil) if err != nil { return "" }