github.com/ilhicas/nomad@v0.11.8/drivers/mock/utils_test.go (about)

     1  package mock
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestParseDuration(t *testing.T) {
    11  	t.Run("valid case", func(t *testing.T) {
    12  		v, err := parseDuration("10m")
    13  		require.NoError(t, err)
    14  		require.Equal(t, 10*time.Minute, v)
    15  	})
    16  
    17  	t.Run("invalid case", func(t *testing.T) {
    18  		v, err := parseDuration("10")
    19  		require.Error(t, err)
    20  		require.Equal(t, time.Duration(0), v)
    21  	})
    22  
    23  	t.Run("empty case", func(t *testing.T) {
    24  		v, err := parseDuration("")
    25  		require.NoError(t, err)
    26  		require.Equal(t, time.Duration(0), v)
    27  	})
    28  
    29  }