Skip to content

Commit

Permalink
fix: linting and formatting run
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrellbor authored and gavv committed Oct 3, 2023
1 parent 82d3394 commit f99fd63
Showing 1 changed file with 48 additions and 50 deletions.
98 changes: 48 additions & 50 deletions expect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

}

0 comments on commit f99fd63

Please sign in to comment.