github.com/lyft/flytestdlib@v0.3.12-0.20210213045714-8cdd111ecda1/internal/utils/parsers_test.go (about) 1 package utils 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestMustParseURL(t *testing.T) { 10 t.Run("Valid URL", func(t *testing.T) { 11 MustParseURL("http://something-profound-localhost.com") 12 }) 13 14 t.Run("Invalid URL", func(t *testing.T) { 15 assert.Panics(t, func() { 16 MustParseURL("invalid_url:is_here\\") 17 }) 18 }) 19 } 20 21 func TestRefUint32(t *testing.T) { 22 input := int(5) 23 res := RefInt(input) 24 assert.Equal(t, input, *res) 25 } 26 27 func TestMustCompileRegexp(t *testing.T) { 28 t.Run("Valid regexp", func(t *testing.T) { 29 MustCompileRegexp("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$") 30 }) 31 32 t.Run("Invalid regexp", func(t *testing.T) { 33 assert.Panics(t, func() { 34 MustCompileRegexp("^(") 35 }) 36 }) 37 }