From: Reinhard Tartler Date: Sat, 26 Sep 2026 11:00:06 -0400 Subject: Fix test failures with Go 1.27 Closes: #1146197 Bug-Debian: https://bugs.debian.org/1146197 Forwarded: https://github.com/go-quicktest/qt/issues/26#issuecomment-5847269126 Author: Reinhard Tartler --- checker_test.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/checker_test.go b/checker_test.go index 9678f40..668796b 100644 --- a/checker_test.go +++ b/checker_test.go @@ -1777,14 +1777,14 @@ want: }, { about: "JSONEquals cannot marshal expected value", checker: qt.JSONEquals([]byte(`null`), jsonErrorMarshaler{}), - expectedCheckFailure: ` + expectedCheckFailure: fmt.Sprintf(` error: - bad check: cannot marshal expected contents: json: error calling MarshalJSON for type qt_test.jsonErrorMarshaler: qt json marshal error -`, - expectedNegateFailure: ` + bad check: cannot marshal expected contents: %s +`, mustJSONMarshalErr(jsonErrorMarshaler{})), + expectedNegateFailure: fmt.Sprintf(` error: - bad check: cannot marshal expected contents: json: error calling MarshalJSON for type qt_test.jsonErrorMarshaler: qt json marshal error -`, + bad check: cannot marshal expected contents: %s +`, mustJSONMarshalErr(jsonErrorMarshaler{})), }, { about: "JSONEquals with []byte", checker: qt.JSONEquals([]byte("null"), nil), @@ -1799,14 +1799,14 @@ want: }, { about: "JSONEquals with RawMessage", checker: qt.JSONEquals([]byte("null"), json.RawMessage("null")), - expectedNegateFailure: ` + expectedNegateFailure: fmt.Sprintf(` error: unexpected success got: []uint8("null") want: - json.RawMessage("null") -`, + %s +`, qt.Format(json.RawMessage("null"))), }, { about: "CodecEquals with bad marshal", checker: qt.CodecEquals( @@ -2036,6 +2036,14 @@ func mustJSONUnmarshalErr(s string) error { return err } +func mustJSONMarshalErr(v any) error { + _, err := json.Marshal(v) + if err == nil { + panic("want JSON marshal error, got nil") + } + return err +} + func tilde2bq(s string) string { return strings.Replace(s, "~", "`", -1) }