github.com/lyft/flytestdlib@v0.3.12-0.20210213045714-8cdd111ecda1/internal/utils/parsers.go (about)

     1  package utils
     2  
     3  import (
     4  	"net/url"
     5  	"regexp"
     6  )
     7  
     8  // A utility function to be used in tests. It parses urlString as url.URL or panics if it's invalid.
     9  func MustParseURL(urlString string) url.URL {
    10  	u, err := url.Parse(urlString)
    11  	if err != nil {
    12  		panic(err)
    13  	}
    14  
    15  	return *u
    16  }
    17  
    18  // A utility function to be used in tests. It returns the address of the passed value.
    19  func RefInt(val int) *int {
    20  	return &val
    21  }
    22  
    23  // A utility function to be used in tests. It compiles regexpString as regexp.Regexp or panics if it's invalid.
    24  func MustCompileRegexp(regexpString string) regexp.Regexp {
    25  	r, err := regexp.Compile(regexpString)
    26  	if err != nil {
    27  		panic(err)
    28  	}
    29  
    30  	return *r
    31  }