scenariostest

package
v0.0.0-...-d71de7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const HTTPX_FAST = "HTTPX_FAST"

Set this environment variable to skip slow tests

Variables

This section is empty.

Functions

func ExpectServerToRun

func ExpectServerToRun(
	t *testing.T,
	name string,
	CreateServer scenarios.CreateServerFunc,
	ApplyServer scenarios.ApplyServerFunc,
	ListenAndServe scenarios.ListenAndServeFunc,
)

ExpectServerToRun creates test scenarios for validating a server serving behaviors.

func ValidateSlowBodyRead

func ValidateSlowBodyRead(
	t *testing.T,
	name string,
	CreateServer scenarios.CreateServerFunc,
	expectToPass bool,
)

func ValidateSlowloris

func ValidateSlowloris(
	t *testing.T,
	name string,
	CreateServer scenarios.CreateServerFunc,
	expectToPass bool,
)

Types

type ConnStateCounter

type ConnStateCounter struct {
	CountStateNew    atomic.Int64
	CountActiveState atomic.Int64
	CountClosedState atomic.Int64
}

func (*ConnStateCounter) Count

func (c *ConnStateCounter) Count(conn net.Conn, state http.ConnState)

type TestContext

type TestContext struct {
	testing.TB
}

func New

func New(t testing.TB) *TestContext

New creates a TestContext instance.

func (*TestContext) CreateFastCheckContext

func (tc *TestContext) CreateFastCheckContext() (context.Context, context.CancelFunc)

func (*TestContext) ExpectToServeResponse

func (tc *TestContext) ExpectToServeResponse(
	ctx context.Context,
	addr string,
	checkResp func(tc *TestContext, resp *http.Response, body []byte),
)

func (*TestContext) ListenTCP

func (tc *TestContext) ListenTCP() net.Listener

ListenTCP listens on the local TCP network with random port and returns the address. The connection will be closed when the test is finished.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL