Skip to content

Commit

Permalink
fix tests for gotip and go1.15.x
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Jun 10, 2020
1 parent 69c44b2 commit 7874f47
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"math"
"os"
"reflect"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -551,7 +552,16 @@ func TestMustGetParsedDuration(t *testing.T) {
input := "key = 123ms\nkey2 = ghi"
p := mustParse(t, input)
assert.Equal(t, p.MustGetParsedDuration("key"), 123*time.Millisecond)
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, "time: invalid duration ghi")

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`)
}

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

Expand Down

0 comments on commit 7874f47

Please sign in to comment.