refactor: unify the error paths in one Path type
Test / test (push) Canceled after 1m31s

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-09-22 00:34:48 +02:00
parent a8a2fcf8c3
commit b02471c09a
6 changed files with 119 additions and 69 deletions
+12 -12
View File
@@ -402,8 +402,8 @@ func TestMarshalRejectsNilMarshalerResult(t *testing.T) {
if !ok {
t.Fatalf("expected an *EncodeError, got %T: %v", err, err)
}
if ee.Path != "f" {
t.Fatalf("Path = %q, want %q", ee.Path, "f")
if ee.Path.String() != "f" {
t.Fatalf("Path = %v, want f", ee.Path)
}
// Inside a value array the nil result used to reach reflection as a zero
@@ -1339,8 +1339,8 @@ func TestEncodeErrorCarriesPath(t *testing.T) {
if !ok {
t.Fatalf("expected an *EncodeError, got %T: %v", err, err)
}
if ee.Path != "server.port" {
t.Fatalf("Path = %q, want %q", ee.Path, "server.port")
if ee.Path.String() != "server.port" {
t.Fatalf("Path = %v, want server.port", ee.Path)
}
if ee.Err == nil || ee.Err.Error() != "bad timestamp" {
t.Fatalf("Err = %v", ee.Err)
@@ -1359,8 +1359,8 @@ func TestEncodeErrorTopLevelPathHasNoLeadingDot(t *testing.T) {
if !ok {
t.Fatalf("expected an *EncodeError, got %T: %v", err, err)
}
if ee.Path != "port" {
t.Fatalf("Path = %q, want %q", ee.Path, "port")
if ee.Path.String() != "port" {
t.Fatalf("Path = %v, want port", ee.Path)
}
if err.Error() != "interpres: port: bad timestamp" {
t.Fatalf("message = %q", err.Error())
@@ -1382,8 +1382,8 @@ func TestEncodeErrorHeterogeneousArrayPath(t *testing.T) {
if !ok {
t.Fatalf("expected an *EncodeError, got %T: %v", err, err)
}
if ee.Path != "items[0]" {
t.Fatalf("Path = %q, want %q", ee.Path, "items[0]")
if ee.Path.String() != "items[0]" {
t.Fatalf("Path = %v, want items[0]", ee.Path)
}
}
@@ -1541,8 +1541,8 @@ func TestMarshalTextErrorCarriesPath(t *testing.T) {
if !ok {
t.Fatalf("expected an *EncodeError, got %T: %v", err, err)
}
if ee.Path != "inner.f" {
t.Fatalf("Path = %q, want %q", ee.Path, "inner.f")
if ee.Path.String() != "inner.f" {
t.Fatalf("Path = %v, want inner.f", ee.Path)
}
}
@@ -1920,8 +1920,8 @@ func TestMarshalerElementErrorCarriesPath(t *testing.T) {
if !ok {
t.Fatalf("expected an *EncodeError, got %T: %v", err, err)
}
if ee.Path != "items[1]" {
t.Fatalf("Path = %q, want %q", ee.Path, "items[1]")
if ee.Path.String() != "items[1]" {
t.Fatalf("Path = %v, want items[1]", ee.Path)
}
}