...
1
2
3
4 package properties
5
6 import (
7 "testing"
8 "time"
9
10 "github.com/magiconair/properties/assert"
11 )
12
13
14
15
16
17
18
19 func TestMustGetParsedDuration(t *testing.T) {
20 input := "key = 123ms\nkey2 = ghi"
21 p := mustParse(t, input)
22 assert.Equal(t, p.MustGetParsedDuration("key"), 123*time.Millisecond)
23 assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration "ghi"`)
24 assert.Panic(t, func() { p.MustGetParsedDuration("invalid") }, "unknown property: invalid")
25 }
26
View as plain text