From 3ac04b0377202553486d677d314f5f5df1beaf5e Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Mon, 21 Mar 2022 22:25:55 +0900 Subject: [PATCH] resolve broken test case --- networking/failback.go | 2 +- types/json.go | 2 +- types/json_test.go | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/networking/failback.go b/networking/failback.go index 9b7b72c..842858c 100644 --- a/networking/failback.go +++ b/networking/failback.go @@ -63,7 +63,7 @@ func (d *RoundrobinDialer) resolveHost(ctx context.Context, network, connectAddr } if resolvedIPs, err = d.Dialer.Resolver.LookupIP(ctx, network, host); err != nil { - log.Printf("cannot resolve host %s : %s", err) + log.Printf("cannot resolve host %s(%s) : %s", host, network, err) return } diff --git a/types/json.go b/types/json.go index d6ec088..8de5812 100644 --- a/types/json.go +++ b/types/json.go @@ -20,7 +20,7 @@ func (j JSON) String() string { // Unmarshal your JSON variable into dest. func (j JSON) Unmarshal(dest any) error { - iter := misc.JSONCodec.BorrowIterator(nil) + iter := misc.JSONCodec.BorrowIterator(j) defer misc.JSONCodec.ReturnIterator(iter) iter.ReadVal(dest) return iter.Error diff --git a/types/json_test.go b/types/json_test.go index 9ba2327..37be825 100644 --- a/types/json_test.go +++ b/types/json_test.go @@ -18,12 +18,12 @@ func TestJSONUnmarshal(t *testing.T) { t.Parallel() type JSONTest struct { - Name string - Age int + Name string `json:"name"` + Age int `json:"age"` } var jt JSONTest - j := JSON(`{"Name":"hi","Age":15}`) + j := JSON(`{"name":"hi","age":15}`) err := j.Unmarshal(&jt) if err != nil { t.Error(err) @@ -41,8 +41,8 @@ func TestJSONMarshal(t *testing.T) { t.Parallel() type JSONTest struct { - Name string - Age int + Name string `json:"name"` + Age int `json:"age"` } jt := JSONTest{ Name: "hi", @@ -55,8 +55,8 @@ func TestJSONMarshal(t *testing.T) { t.Error(err) } - if j.String() != `{"Name":"hi","Age":15}` { - t.Errorf("expected %s, got %s", `{"Name":"hi","Age":15}`, j.String()) + if j.String() != `{"name":"hi","age":15}` { + t.Errorf("expected %s, got %s", `{"name":"hi","age":15}`, j.String()) } } @@ -92,7 +92,7 @@ func TestJSONMarshalJSON(t *testing.T) { func TestJSONValue(t *testing.T) { t.Parallel() - j := JSON(`{"Name":"hi","Age":15}`) + j := JSON(`{"name":"hi","age":15}`) v, err := j.Value() if err != nil { t.Error(err)