urfave-cli/altsrc/map_input_source_test.go

25 lines
579 B
Go
Raw Normal View History

2017-07-06 12:05:23 +00:00
package altsrc
import (
"testing"
"time"
)
func TestMapDuration(t *testing.T) {
inputSource := NewMapInputSource(
"test",
map[interface{}]interface{}{
2017-07-06 12:05:23 +00:00
"duration_of_duration_type": time.Minute,
"duration_of_string_type": "1m",
"duration_of_int_type": 1000,
})
2017-07-06 12:05:23 +00:00
d, err := inputSource.Duration("duration_of_duration_type")
expect(t, time.Minute, d)
expect(t, nil, err)
d, err = inputSource.Duration("duration_of_string_type")
expect(t, time.Minute, d)
expect(t, nil, err)
_, err = inputSource.Duration("duration_of_int_type")
2017-07-06 12:05:23 +00:00
refute(t, nil, err)
}