-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from maage/beta-1
TestMustGetParsedDuration: drop version tests
- Loading branch information
Showing
3 changed files
with
50 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//go:build go1.15 | ||
// +build go1.15 | ||
|
||
package properties | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/magiconair/properties/assert" | ||
) | ||
|
||
// TestMustGetParsedDuration works with go1.15 and beyond where the panic | ||
// message was changed slightly. We keep this test (!) here to demonstrate the | ||
// backwards compatibility and to keep the author happy as long as it does not | ||
// affect any real users. Thank you! Frank :) | ||
// | ||
// See https://github.com/magiconair/properties/pull/63 | ||
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"`) | ||
assert.Panic(t, func() { p.MustGetParsedDuration("invalid") }, "unknown property: invalid") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//go:build !go1.15 | ||
// +build !go1.15 | ||
|
||
package properties | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/magiconair/properties/assert" | ||
) | ||
|
||
// TestMustGetParsedDuration works with go before go1.15 where the panic | ||
// message was changed slightly. We keep this test (!) here to demonstrate the | ||
// backwards compatibility and to keep the author happy as long as it does not | ||
// affect any real users. Thank you! Frank :) | ||
// | ||
// See https://github.com/magiconair/properties/pull/63 | ||
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`) | ||
assert.Panic(t, func() { p.MustGetParsedDuration("invalid") }, "unknown property: invalid") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters