| 1 |
From: Reinhard Tartler <[email protected]> |
| 2 |
Date: Sat, 26 Sep 2026 11:00:06 -0400 |
| 3 |
Subject: Fix test failures with Go 1.27 |
| 4 |
|
| 5 |
Closes: #1146197 |
| 6 |
Bug-Debian: https://bugs.debian.org/1146197 |
| 7 |
Forwarded: https://github.com/go-quicktest/qt/issues/26#issuecomment-5847269126 |
| 8 |
Author: Reinhard Tartler <[email protected]> |
| 9 |
--- |
| 10 |
checker_test.go | 26 +++++++++++++++++--------- |
| 11 |
1 file changed, 17 insertions(+), 9 deletions(-) |
| 12 |
|
| 13 |
diff --git a/checker_test.go b/checker_test.go |
| 14 |
index 9678f40..668796b 100644 |
| 15 |
--- a/checker_test.go |
| 16 |
+++ b/checker_test.go |
| 17 |
@@ -1777,14 +1777,14 @@ want: |
| 18 |
}, { |
| 19 |
about: "JSONEquals cannot marshal expected value", |
| 20 |
checker: qt.JSONEquals([]byte(`null`), jsonErrorMarshaler{}), |
| 21 |
- expectedCheckFailure: ` |
| 22 |
+ expectedCheckFailure: fmt.Sprintf(` |
| 23 |
error: |
| 24 |
- bad check: cannot marshal expected contents: json: error calling MarshalJSON for type qt_test.jsonErrorMarshaler: qt json marshal error |
| 25 |
-`, |
| 26 |
- expectedNegateFailure: ` |
| 27 |
+ bad check: cannot marshal expected contents: %s |
| 28 |
+`, mustJSONMarshalErr(jsonErrorMarshaler{})), |
| 29 |
+ expectedNegateFailure: fmt.Sprintf(` |
| 30 |
error: |
| 31 |
- bad check: cannot marshal expected contents: json: error calling MarshalJSON for type qt_test.jsonErrorMarshaler: qt json marshal error |
| 32 |
-`, |
| 33 |
+ bad check: cannot marshal expected contents: %s |
| 34 |
+`, mustJSONMarshalErr(jsonErrorMarshaler{})), |
| 35 |
}, { |
| 36 |
about: "JSONEquals with []byte", |
| 37 |
checker: qt.JSONEquals([]byte("null"), nil), |
| 38 |
@@ -1799,14 +1799,14 @@ want: |
| 39 |
}, { |
| 40 |
about: "JSONEquals with RawMessage", |
| 41 |
checker: qt.JSONEquals([]byte("null"), json.RawMessage("null")), |
| 42 |
- expectedNegateFailure: ` |
| 43 |
+ expectedNegateFailure: fmt.Sprintf(` |
| 44 |
error: |
| 45 |
unexpected success |
| 46 |
got: |
| 47 |
[]uint8("null") |
| 48 |
want: |
| 49 |
- json.RawMessage("null") |
| 50 |
-`, |
| 51 |
+ %s |
| 52 |
+`, qt.Format(json.RawMessage("null"))), |
| 53 |
}, { |
| 54 |
about: "CodecEquals with bad marshal", |
| 55 |
checker: qt.CodecEquals( |
| 56 |
@@ -2036,6 +2036,14 @@ func mustJSONUnmarshalErr(s string) error { |
| 57 |
return err |
| 58 |
} |
| 59 |
|
| 60 |
+func mustJSONMarshalErr(v any) error { |
| 61 |
+ _, err := json.Marshal(v) |
| 62 |
+ if err == nil { |
| 63 |
+ panic("want JSON marshal error, got nil") |
| 64 |
+ } |
| 65 |
+ return err |
| 66 |
+} |
| 67 |
+ |
| 68 |
func tilde2bq(s string) string { |
| 69 |
return strings.Replace(s, "~", "`", -1) |
| 70 |
} |