From 48b7340e9645f95d074407579e09a96a898b4a3f Mon Sep 17 00:00:00 2001 From: Craig Davison Date: Wed, 26 Jul 2023 15:37:34 -0600 Subject: [PATCH] captureTestingT.checkResultAndErrMsg --- assert/assertions_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/assert/assertions_test.go b/assert/assertions_test.go index 5e71beb3e..582bf5dcc 100644 --- a/assert/assertions_test.go +++ b/assert/assertions_test.go @@ -2888,13 +2888,13 @@ 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") @@ -2902,7 +2902,7 @@ func checkResultAndErrMsg(t *testing.T, expectedRes, res bool, expectedErrMsg, r 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 { @@ -2977,7 +2977,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) }) } } @@ -3040,7 +3040,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) }) } }