From f99fd6335988302f94fac7732ca736c861c54d6e Mon Sep 17 00:00:00 2001 From: Darrel Idiagbor Date: Mon, 1 May 2023 16:10:12 +0200 Subject: [PATCH] fix: linting and formatting run --- expect_test.go | 98 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/expect_test.go b/expect_test.go index 98912b5f7..21919fa5d 100644 --- a/expect_test.go +++ b/expect_test.go @@ -764,66 +764,64 @@ func TestExpect_Adapters(t *testing.T) { }) } - func TestReporterAndAssertionHandler(t *testing.T) { mainRep := newMockReporter(t) mainAssertionHandler := &mockAssertionHandler{} - config := Config{ - BaseURL: "http://example.com", - Reporter: mainRep, - } + config := Config{ + BaseURL: "http://example.com", + Reporter: mainRep, + } assertionConfig := Config{ - BaseURL: "http://example.com", + BaseURL: "http://example.com", AssertionHandler: mainAssertionHandler, } - cases := []struct{ - name string - config Config - hasReporter bool - wantEqual chainResult - }{ - { - name: "Response reported failure with reporter", - config: config, - hasReporter: true, - wantEqual: failure, - }, - { - name: "Response reported failure with assertion handler", - config: assertionConfig, - hasReporter: true, - wantEqual: failure, - }, - } - - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - subRep := newMockReporter(t); - subAssertionHandler := &mockAssertionHandler{} - var req2 *Request - - req1 := NewRequest(config, "GET", "/") - - if tc.hasReporter { - req2 = NewRequest(config, "GET", "/2").WithReporter(subRep) - } else { - req2 = NewRequest(config, "GET", "/2").WithAssertionHandler(subAssertionHandler) - } + cases := []struct { + name string + config Config + hasReporter bool + wantEqual chainResult + }{ + { + name: "Response reported failure with reporter", + config: config, + hasReporter: true, + wantEqual: failure, + }, + { + name: "Response reported failure with assertion handler", + config: assertionConfig, + hasReporter: true, + wantEqual: failure, + }, + } - resp1 := req1.Expect().Status(200) - resp2 := req2.Expect().Status(200) + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + subRep := newMockReporter(t) + subAssertionHandler := &mockAssertionHandler{} + var req2 *Request - // Make some assertion that fails on both responses - resp1.JSON().Object().Value("foo").chain.assert(t, failure) - resp2.JSON().Object().Value("foo").chain.assert(t, failure) + req1 := NewRequest(config, "GET", "/") - resp1.chain.assert(t, tc.wantEqual) - resp2.chain.assert(t, tc.wantEqual) - }) - } - -} + if tc.hasReporter { + req2 = NewRequest(config, "GET", "/2").WithReporter(subRep) + } else { + req2 = NewRequest(config, "GET", "/2").WithAssertionHandler(subAssertionHandler) + } + + resp1 := req1.Expect().Status(200) + resp2 := req2.Expect().Status(200) + // Make some assertion that fails on both responses + resp1.JSON().Object().Value("foo").chain.assert(t, failure) + resp2.JSON().Object().Value("foo").chain.assert(t, failure) + + resp1.chain.assert(t, tc.wantEqual) + resp2.chain.assert(t, tc.wantEqual) + }) + } + +}