From b267a43b23648d3d686a1939d9b5d02ac7c9b741 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Sun, 27 Jan 2019 03:26:12 +0100 Subject: [PATCH] Add int slice test to unmarshal --- viper_test.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/viper_test.go b/viper_test.go index f325b82..a689272 100644 --- a/viper_test.go +++ b/viper_test.go @@ -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) {