mirror of
https://github.com/spf13/viper
synced 2025-05-06 20:27:17 +00:00
Issue-105 Add time.Duration in TestUnmarshal
This commit is contained in:
parent
e38b8a3bb3
commit
aebf0fcdc5
1 changed files with 6 additions and 4 deletions
|
@ -453,10 +453,12 @@ func TestRecursiveAliases(t *testing.T) {
|
||||||
func TestUnmarshal(t *testing.T) {
|
func TestUnmarshal(t *testing.T) {
|
||||||
SetDefault("port", 1313)
|
SetDefault("port", 1313)
|
||||||
Set("name", "Steve")
|
Set("name", "Steve")
|
||||||
|
Set("duration", "1s1ms")
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
Port int
|
Port int
|
||||||
Name string
|
Name string
|
||||||
|
Duration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
var C config
|
var C config
|
||||||
|
@ -466,14 +468,14 @@ func TestUnmarshal(t *testing.T) {
|
||||||
t.Fatalf("unable to decode into struct, %v", err)
|
t.Fatalf("unable to decode into struct, %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, &C, &config{Name: "Steve", Port: 1313})
|
assert.Equal(t, &C, &config{Name: "Steve", Port: 1313, Duration: time.Second + time.Millisecond})
|
||||||
|
|
||||||
Set("port", 1234)
|
Set("port", 1234)
|
||||||
err = Unmarshal(&C)
|
err = Unmarshal(&C)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to decode into struct, %v", err)
|
t.Fatalf("unable to decode into struct, %v", err)
|
||||||
}
|
}
|
||||||
assert.Equal(t, &C, &config{Name: "Steve", Port: 1234})
|
assert.Equal(t, &C, &config{Name: "Steve", Port: 1234, Duration: time.Second + time.Millisecond})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBindPFlags(t *testing.T) {
|
func TestBindPFlags(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue