Skip to content

Commit

Permalink
captureTestingT.checkResultAndErrMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
craig65535 committed Jul 31, 2023
1 parent 8e8d1e1 commit 18ce90d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions assert/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2894,21 +2894,21 @@ func (ctt *captureTestingT) Errorf(format string, args ...interface{}) {
ctt.msg = fmt.Sprintf(format, args...)
}

func checkResultAndErrMsg(t *testing.T, expectedRes, res bool, expectedErrMsg, rawErrOutput string) {
func (ctt *captureTestingT) checkResultAndErrMsg(t *testing.T, expectedRes, res bool, expectedErrMsg string) {
t.Helper()
if res != expectedRes {
t.Errorf("Should return %t", expectedRes)
return
}
contents := parseLabeledOutput(rawErrOutput)
contents := parseLabeledOutput(ctt.msg)
if res == true {
if contents != nil {
t.Errorf("Should not log an error")
}
return
}
if contents == nil {
t.Errorf("Should log an error. Log output: %v", rawErrOutput)
t.Errorf("Should log an error. Log output: %v", ctt.msg)
return
}
for _, content := range contents {
Expand Down Expand Up @@ -2983,7 +2983,7 @@ func TestErrorIs(t *testing.T) {
mockT := new(captureTestingT)
t.Run(fmt.Sprintf("ErrorIs(%#v,%#v)", tt.err, tt.target), func(t *testing.T) {
res := ErrorIs(mockT, tt.err, tt.target)
checkResultAndErrMsg(t, tt.result, res, tt.resultErrMsg, mockT.msg)
mockT.checkResultAndErrMsg(t, tt.result, res, tt.resultErrMsg)
})
}
}
Expand Down Expand Up @@ -3046,7 +3046,7 @@ func TestNotErrorIs(t *testing.T) {
mockT := new(captureTestingT)
t.Run(fmt.Sprintf("NotErrorIs(%#v,%#v)", tt.err, tt.target), func(t *testing.T) {
res := NotErrorIs(mockT, tt.err, tt.target)
checkResultAndErrMsg(t, tt.result, res, tt.resultErrMsg, mockT.msg)
mockT.checkResultAndErrMsg(t, tt.result, res, tt.resultErrMsg)
})
}
}
Expand Down

0 comments on commit 18ce90d

Please sign in to comment.