Skip to content

Commit

Permalink
Properly compare versions equal or over to 1.15 in TestMustGetParsedD…
Browse files Browse the repository at this point in the history
…uration

Fix #52

Signed-off-by: Robert-André Mauchin <zebob.m@gmail.com>
  • Loading branch information
eclipseo committed Jan 24, 2021
1 parent 0e5c090 commit 45d7772
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,17 @@ func TestMustGetParsedDuration(t *testing.T) {
assert.Equal(t, p.MustGetParsedDuration("key"), 123*time.Millisecond)

ver := runtime.Version()
switch {
// gotip and go1.15 will return `time: invalid duration "ghi"`
case !strings.HasPrefix(ver, "go") || strings.HasPrefix(ver, "go1.15"):
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration "ghi"`)
default:
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration ghi`)
if strings.HasPrefix(ver, "go") {
ver_minor := ver[4:6]
switch {
// gotip and go1.15 will return `time: invalid duration "ghi"`
case ver_minor >= "15":
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration "ghi"`)
default:
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration ghi`)
}
} else {
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration "ghi"`)
}

assert.Panic(t, func() { p.MustGetParsedDuration("invalid") }, "unknown property: invalid")
Expand Down

0 comments on commit 45d7772

Please sign in to comment.