testx

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnvRaw

func GetEnvRaw(key string) string

func GetEnvWithPrefix

func GetEnvWithPrefix(key string) string

func ITConfigFromEnv

func ITConfigFromEnv(t *testing.T) *config.Config

func ITCtx

func ITCtx(t *testing.T, d time.Duration) context.Context

func ITHttpClient

func ITHttpClient(t *testing.T, ctx context.Context, cfg *config.Config, log *slog.Logger) *http.Client

func LogJson

func LogJson(t *testing.T, v any)

func Logger

func Logger(t *testing.T) *slog.Logger

func RequireEnv

func RequireEnv(t testing.TB, key string) string

func RequireEnvRaw

func RequireEnvRaw(t testing.TB, key string) string

func RequireEnvWithPrefix

func RequireEnvWithPrefix(t testing.TB, key string) string

func RequireEnvs

func RequireEnvs(t testing.TB, keys ...string) map[string]string

func RequireEnvsWithPrefix

func RequireEnvsWithPrefix(t testing.TB, keys ...string) map[string]string

func TestAuthJSON200Response

func TestAuthJSON200Response(t *testing.T, status int, token string, raw string) *oauth2.RequestTokenResponse

func TestConfig

func TestConfig(t *testing.T) *config.Config

Types

type AuthServerCookie

type AuthServerCookie struct {
	TS      *httptest.Server
	BaseURL string
}

func StartAuthServerCookie

func StartAuthServerCookie(t testing.TB, opts CookieAuthOpts) *AuthServerCookie

func (*AuthServerCookie) Close

func (s *AuthServerCookie) Close()

type AuthServerXsrf

type AuthServerXsrf struct {
	TS      *httptest.Server
	BaseURL string
}

func StartAuthServerXSRF

func StartAuthServerXSRF(t testing.TB, opts XsrfAuthOpts) *AuthServerXsrf

func (*AuthServerXsrf) Close

func (s *AuthServerXsrf) Close()

type CookieAuthOpts

type CookieAuthOpts struct {
	LoginPath  string // default "/api/login"
	CookieName string // default "sessionid"
	SetCookie  bool   // default true
	StatusCode int    // default 200
	ExpectUser struct {
		Name     string // default "demo"
		Password string // default "demo"
	}
}

type FakeServer

type FakeServer struct {
	FS      *httptest.Server
	BaseURL string
}

func NewFakeServer

func NewFakeServer(t *testing.T) *FakeServer

type XsrfAuthOpts

type XsrfAuthOpts struct {
	SetSessionCookie bool // default true
	SetXSRFToken     bool // default true
}

Jump to

Keyboard shortcuts

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