2018-11-13 03:15:57 +00:00
|
|
|
package mock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2022-03-15 12:42:43 +00:00
|
|
|
"github.com/hashicorp/nomad/ci"
|
2018-11-13 03:15:57 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseDuration(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
|
|
|
|
2018-11-13 03:15:57 +00:00
|
|
|
t.Run("valid case", func(t *testing.T) {
|
|
|
|
v, err := parseDuration("10m")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 10*time.Minute, v)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("invalid case", func(t *testing.T) {
|
|
|
|
v, err := parseDuration("10")
|
|
|
|
require.Error(t, err)
|
|
|
|
require.Equal(t, time.Duration(0), v)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("empty case", func(t *testing.T) {
|
|
|
|
v, err := parseDuration("")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, time.Duration(0), v)
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|