1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
From: Nicolas Peugnet <nicolas@club1.fr>
Date: Tue, 4 Mar 2025 11:13:23 +0100
Subject: Fix tests compatibility with go 1.24
This fixes the following test failure:
=== RUN TestLogRotation/invalid_logger_config
config_test.go:440: test "invalid logger config", expected error:
invalid log rotation config: json: cannot unmarshal bool into Go
struct field logRotationConfig.maxsize of type int,
got:
invalid log rotation config: json: cannot unmarshal bool into Go
struct field logRotationConfig.Logger.maxsize of type int
It seems go 1.24 changed the error messages of the encoding/json
package. Ideally the test would only assert the part of the message
produced by etcd, but it is easier to simply not check it in Debian.
This allows to make the test compatible with more go versions that just
go 1.24.
---
server/embed/config_test.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/server/embed/config_test.go b/server/embed/config_test.go
index 7307aa9..a689827 100644
--- a/server/embed/config_test.go
+++ b/server/embed/config_test.go
@@ -415,7 +415,6 @@ func TestLogRotation(t *testing.T) {
logOutputs: []string{"/tmp/path"},
logRotationConfig: `{"maxsize": true}`,
wantErr: true,
- wantErrMsg: errors.New("invalid log rotation config: json: cannot unmarshal bool into Go struct field logRotationConfig.maxsize of type int"),
},
{
name: "improperly formatted logger config",
@@ -436,7 +435,7 @@ func TestLogRotation(t *testing.T) {
if err != nil && !tt.wantErr {
t.Errorf("test %q, unexpected error %v", tt.name, err)
}
- if err != nil && tt.wantErr && tt.wantErrMsg.Error() != err.Error() {
+ if err != nil && tt.wantErrMsg != nil && tt.wantErrMsg.Error() != err.Error() {
t.Errorf("test %q, expected error: %+v, got: %+v", tt.name, tt.wantErrMsg, err)
}
if err == nil && tt.wantErr {
|