Documentation
¶
Index ¶
- Constants
- Variables
- func AssertReceiveChan[T any](t *testing.T, ch <-chan T, timeout time.Duration) T
- func AssertReceiveChanContext[T any](t *testing.T, ctx context.Context, ch <-chan T) T
- func Context(t *testing.T, opts ...ContextOption) context.Context
- func Delete(t *testing.T, url string)
- func Get[R any](t *testing.T, url string) R
- func GetFreeHostPort(t *testing.T) string
- func GetFreePort(t *testing.T) int
- func GetText(t *testing.T, url string) string
- func Post[R any](t *testing.T, url string, req any) R
- func Put[R any](t *testing.T, url string, req any) R
- func RandName() string
- func RandString(length int) string
- type ContextOption
Constants ¶
const LocalIP = "127.0.0.1"
Variables ¶
Functions ¶
func AssertReceiveChan ¶
func GetFreeHostPort ¶
func GetFreePort ¶
GetFreePort returns a TCP port that is available to listen on, for the local host 127.0.0.1.
Copied from: https://github.com/temporalio/cli/blob/main/temporalcli/devserver/freeport.go
This works by binding a new TCP socket on port 0, which requests the OS to allocate a free port. There is no strict guarantee that the port will remain available after this function returns, but it should be safe to assume that a given port will not be allocated again to any process on this machine within a few seconds.
On Unix-based systems, binding to the port returned by this function requires setting the `SO_REUSEADDR` socket option (Go already does that by default, but other languages may not); otherwise, the OS may fail with a message such as "address already in use". Windows default behavior is already appropriate in this regard; on that platform, `SO_REUSEADDR` has a different meaning and should not be set (setting it may have unpredictable consequences).
func RandString ¶
Types ¶
type ContextOption ¶
type ContextOption func(opts *contextOptions)
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ContextOption