chore: add more tests

This commit is contained in:
kevin
2023-03-02 09:57:18 +08:00
parent a432b121fb
commit 9bfa63d995
2 changed files with 14 additions and 2 deletions

View File

@@ -1007,9 +1007,19 @@ func TestLoadNamedFieldOverwritten(t *testing.T) {
)
var c Config
input := []byte(`{"Val": {"Elem": {"Key": {"Value": "Value"}}}}`)
input := []byte(`{"Val": {"Elem": "Value"}}`)
assert.ErrorAs(t, LoadFromJsonBytes(input, &c), &dupErr)
})
t.Run("overwritten named struct", func(t *testing.T) {
type Config struct {
Val chan int
}
var c Config
input := []byte(`{"Val": 1}`)
assert.Error(t, LoadFromJsonBytes(input, &c))
})
}
func createTempFile(ext, text string) (string, error) {