mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
Add int slice test to unmarshal
This commit is contained in:
parent
b52b215be2
commit
b267a43b23
1 changed files with 23 additions and 2 deletions
|
@ -516,11 +516,13 @@ func TestUnmarshal(t *testing.T) {
|
|||
SetDefault("port", 1313)
|
||||
Set("name", "Steve")
|
||||
Set("duration", "1s1ms")
|
||||
Set("modes", []int{1, 2, 3})
|
||||
|
||||
type config struct {
|
||||
Port int
|
||||
Name string
|
||||
Duration time.Duration
|
||||
Modes []int
|
||||
}
|
||||
|
||||
var C config
|
||||
|
@ -530,14 +532,33 @@ func TestUnmarshal(t *testing.T) {
|
|||
t.Fatalf("unable to decode into struct, %v", err)
|
||||
}
|
||||
|
||||
assert.Equal(t, &config{Name: "Steve", Port: 1313, Duration: time.Second + time.Millisecond}, &C)
|
||||
assert.Equal(
|
||||
t,
|
||||
&config{
|
||||
Name: "Steve",
|
||||
Port: 1313,
|
||||
Duration: time.Second + time.Millisecond,
|
||||
Modes: []int{1, 2, 3},
|
||||
},
|
||||
&C,
|
||||
)
|
||||
|
||||
Set("port", 1234)
|
||||
err = Unmarshal(&C)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to decode into struct, %v", err)
|
||||
}
|
||||
assert.Equal(t, &config{Name: "Steve", Port: 1234, Duration: time.Second + time.Millisecond}, &C)
|
||||
|
||||
assert.Equal(
|
||||
t,
|
||||
&config{
|
||||
Name: "Steve",
|
||||
Port: 1234,
|
||||
Duration: time.Second + time.Millisecond,
|
||||
Modes: []int{1, 2, 3},
|
||||
},
|
||||
&C,
|
||||
)
|
||||
}
|
||||
|
||||
func TestUnmarshalWithDecoderOptions(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue