Skip to content

Commit

Permalink
TestMustGetParsedDuration: drop version tests
Browse files Browse the repository at this point in the history
Fails:

% go version
go version go1.18beta2 linux/amd64

As per:

	https://go.dev/doc/devel/release#policy

Supported versions are today 1.16 and 1.17, so we can drop this brittle check.
  • Loading branch information
maage committed Feb 22, 2022
1 parent f999e06 commit 9a74999
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions properties_test.go
Expand Up @@ -11,8 +11,6 @@ import (
"os"
"reflect"
"regexp"
"runtime"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -560,24 +558,7 @@ func TestMustGetParsedDuration(t *testing.T) {
input := "key = 123ms\nkey2 = ghi"
p := mustParse(t, input)
assert.Equal(t, p.MustGetParsedDuration("key"), 123*time.Millisecond)

// parse runtime.Version into major and minor version
var major, minor int
ver := strings.Split(runtime.Version(), ".")
devel := !strings.HasPrefix(ver[0], "go")
major, _ = strconv.Atoi(strings.TrimPrefix(ver[0], "go"))
if len(ver) > 1 {
minor, _ = strconv.Atoi(ver[1])
}

switch {
case devel || major == 1 && minor >= 15:
// go1.15 ... gotip
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration "ghi"`)
default:
// go1.x..go1.14
assert.Panic(t, func() { p.MustGetParsedDuration("key2") }, `time: invalid duration ghi`)
}
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 9a74999

Please sign in to comment.