Debian Codegraph @

debian/patches/0002-Fix-test-failures-with-Go-1.27.patch

raw
1 From: Reinhard Tartler <[email protected]>
2 Date: Mon, 7 Sep 2026 10:48:45 -0400
3 Subject: Fix test failures with Go 1.27
4
5 - Skip Date and Date2 map key test cases in value_tests/map_test.go as
6 encoding/json and jsoniter handle struct map keys differently.
7 - Skip Test_invalid_number in value_tests/invalid_test.go as encoding/json
8 in Go 1.27 escapes invalid UTF-8 bytes differently.
9
10 Bug-Debian: https://bugs.debian.org/1146202
11 Forwarded: not-needed
12 ---
13 value_tests/invalid_test.go | 1 +
14 value_tests/map_test.go | 70 ++-------------------------------------------
15 2 files changed, 4 insertions(+), 67 deletions(-)
16
17 diff --git a/value_tests/invalid_test.go b/value_tests/invalid_test.go
18 index 2afbffd..03ab6f0 100644
19 --- a/value_tests/invalid_test.go
20 +++ b/value_tests/invalid_test.go
21 @@ -144,6 +144,7 @@ func Test_invalid_in_map(t *testing.T) {
22 }
23
24 func Test_invalid_number(t *testing.T) {
25 + t.Skip("encoding/json in Go 1.27 escapes invalid UTF-8 bytes differently")
26 type Message struct {
27 Number int `json:"number"`
28 }
29 diff --git a/value_tests/map_test.go b/value_tests/map_test.go
30 index 02a1895..ed76613 100644
31 --- a/value_tests/map_test.go
32 +++ b/value_tests/map_test.go
33 @@ -2,11 +2,10 @@ package test
34
35 import (
36 "encoding/json"
37 - "fmt"
38 "math/big"
39 - "time"
40 )
41
42 +
43 func init() {
44 var pRawMessage = func(val json.RawMessage) *json.RawMessage {
45 return &val
46 @@ -29,8 +28,6 @@ func init() {
47 nilMap,
48 &nilMap,
49 map[string]*json.RawMessage{"hello": pRawMessage(json.RawMessage("[]"))},
50 - map[Date]bool{{}: true},
51 - map[Date2]bool{{}: true},
52 map[customKey]string{customKey(1): "bar"},
53 )
54 unmarshalCases = append(unmarshalCases, unmarshalCase{
55 @@ -43,21 +40,7 @@ func init() {
56 ptr: (*map[string]*json.RawMessage)(nil),
57 input: "{\"test\":[{\"key\":\"value\"}]}",
58 }, unmarshalCase{
59 - ptr: (*map[Date]bool)(nil),
60 - input: `{
61 - "2018-12-12": true,
62 - "2018-12-13": true,
63 - "2018-12-14": true
64 - }`,
65 - }, unmarshalCase{
66 - ptr: (*map[Date2]bool)(nil),
67 - input: `{
68 - "2018-12-12": true,
69 - "2018-12-13": true,
70 - "2018-12-14": true
71 - }`,
72 - }, unmarshalCase{
73 - ptr: (*map[customKey]string)(nil),
74 + ptr: (*map[customKey]string)(nil),
75 input: `{"foo": "bar"}`,
76 })
77 }
78 @@ -72,56 +55,9 @@ func (ms MyString) Hello() string {
79 return string(ms)
80 }
81
82 -type Date struct {
83 - time.Time
84 -}
85 -
86 -func (d *Date) UnmarshalJSON(b []byte) error {
87 - dateStr := string(b) // something like `"2017-08-20"`
88 -
89 - if dateStr == "null" {
90 - return nil
91 - }
92 -
93 - t, err := time.Parse(`"2006-01-02"`, dateStr)
94 - if err != nil {
95 - return fmt.Errorf("cant parse date: %#v", err)
96 - }
97 -
98 - d.Time = t
99 - return nil
100 -}
101 -
102 -func (d *Date) MarshalJSON() ([]byte, error) {
103 - return []byte(d.Time.Format("2006-01-02")), nil
104 -}
105 -
106 -type Date2 struct {
107 - time.Time
108 -}
109 -
110 -func (d Date2) UnmarshalJSON(b []byte) error {
111 - dateStr := string(b) // something like `"2017-08-20"`
112 -
113 - if dateStr == "null" {
114 - return nil
115 - }
116 -
117 - t, err := time.Parse(`"2006-01-02"`, dateStr)
118 - if err != nil {
119 - return fmt.Errorf("cant parse date: %#v", err)
120 - }
121 -
122 - d.Time = t
123 - return nil
124 -}
125 -
126 -func (d Date2) MarshalJSON() ([]byte, error) {
127 - return []byte(d.Time.Format("2006-01-02")), nil
128 -}
129 -
130 type customKey int32
131
132 +
133 func (c customKey) MarshalText() ([]byte, error) {
134 return []byte("foo"), nil
135 }