From 8cae1c11bd6b6282308933d1f3980d78bf89c0b0 Mon Sep 17 00:00:00 2001 From: johnabass Date: Thu, 6 Jul 2023 00:19:47 -0700 Subject: [PATCH 1/2] fixed a unit test that was incorrectly invoking an inline function --- client/middleware_test.go | 4 ++-- go.mod | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client/middleware_test.go b/client/middleware_test.go index e6e6f16..964c706 100644 --- a/client/middleware_test.go +++ b/client/middleware_test.go @@ -25,9 +25,9 @@ func TestFunc(t *testing.T) { //nolint:bodyclose actual, actualErr := Func(func(r *http.Request) (*http.Response, error) { - assert.True(request == r) + assert.Same(request, r) return expected, expectedErr - })(request) + }).Do(request) assert.True(expected == actual) assert.Equal(expectedErr, actualErr) diff --git a/go.mod b/go.mod index 7d016fc..68d56d5 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,12 @@ module github.com/xmidt-org/httpaux -go 1.14 +go 1.20 require github.com/stretchr/testify v1.8.0 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) From 1c871838fb2bf7e236dae6a928611266b1d3c010 Mon Sep 17 00:00:00 2001 From: johnabass Date: Thu, 6 Jul 2023 00:20:48 -0700 Subject: [PATCH 2/2] same fix: incorrectly invoked an inline function --- roundtrip/middleware_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roundtrip/middleware_test.go b/roundtrip/middleware_test.go index 564a0d4..0ac76c3 100644 --- a/roundtrip/middleware_test.go +++ b/roundtrip/middleware_test.go @@ -26,7 +26,7 @@ func TestFunc(t *testing.T) { actual, actualErr := Func(func(r *http.Request) (*http.Response, error) { assert.True(request == r) return expected, expectedErr - })(request) + }).RoundTrip(request) assert.True(expected == actual) assert.Equal(expectedErr, actualErr)