2017-07-06 12:05:23 +00:00
|
|
|
package altsrc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMapDuration(t *testing.T) {
|
2020-10-08 15:38:59 +00:00
|
|
|
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,
|
2020-10-08 15:38:59 +00:00
|
|
|
})
|
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)
|
2019-12-30 18:41:39 +00:00
|
|
|
_, err = inputSource.Duration("duration_of_int_type")
|
2017-07-06 12:05:23 +00:00
|
|
|
refute(t, nil, err)
|
|
|
|
}
|
2022-10-28 11:49:06 +00:00
|
|
|
|
|
|
|
func TestMapInputSource_Int64Slice(t *testing.T) {
|
|
|
|
inputSource := NewMapInputSource(
|
|
|
|
"test",
|
|
|
|
map[interface{}]interface{}{
|
|
|
|
"test_num": []interface{}{int64(1), int64(2), int64(3)},
|
|
|
|
})
|
|
|
|
d, err := inputSource.Int64Slice("test_num")
|
|
|
|
expect(t, []int64{1, 2, 3}, d)
|
|
|
|
expect(t, nil, err)
|
|
|
|
}
|