Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmashko committed Oct 17, 2023
1 parent 0e6b146 commit 82efb44
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion external/external_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestJsonConfig_IncorrectType_Err(t *testing.T) {
}
}

func TestJsonConfig_NilPointer_Ok(t *testing.T) {
func TestJsonConfig_NilPointerNilInterface_Ok(t *testing.T) {
json := `{"foo":null,"bar":null}`
tc := struct {
Foo *string `json:"foo"`
Expand All @@ -215,6 +215,21 @@ func TestJsonConfig_NilPointer_Ok(t *testing.T) {
}
}

func TestJsonConfig_NilPointerStruct_Ok(t *testing.T) {
json := `{"foo":null}`
tc := struct {
Foo *struct {
Bar string `json:"bar"`
} `json:"foo"`
}{}
if err := envconf.Parse(&tc, option.WithExternal(jsonconf.Json([]byte(json)))); err != nil {
t.Errorf("expected error but got nil")
}
if tc.Foo != nil {
t.Fatalf("unexpected result. expected nil got %v", *tc.Foo)
}
}

func TestJsonConfig_Array_Ok(t *testing.T) {
json := `{"foo":[2, 3, 4, 5]}`
tc := struct {
Expand Down

0 comments on commit 82efb44

Please sign in to comment.