test

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(client *http.Client, config Config, cmd *Command) ([]byte, *http.Header, int, error)

func Execute

func Execute(t *testing.T, config Config, tests []Test)

func InitClient

func InitClient() *http.Client

func Prepare

func Prepare(config Config, commands []Command)

func PrepareRequest

func PrepareRequest(config Config, cmd *Command) (*http.Request, error)

func ReadResponse

func ReadResponse(resp *http.Response) ([]byte, *http.Header, int, error)

func WaitForServer added in v0.4.0

func WaitForServer(baseURL string)

Types

type Command

type Command struct {
	Description string
	Method      string
	Query       string
	Body        string
	Headers     Headers
}

type Config

type Config struct {
	BaseUrl       string
	CommonHeaders Headers
}

type Headers

type Headers http.Header

type Test

type Test struct {
	Description string
	Method      string
	Query       string
	Body        string
	Headers     Headers
	// Expected is the response body to compare against, JSON-normalized.
	// An empty Expected means "no expectation" and the body is NOT checked —
	// so it cannot express PostgREST's `shouldRespondWith ""`. Use
	// ExpectedEmpty for that.
	Expected string
	// ExpectedEmpty asserts the response body is empty. Needed because many
	// ported PostgREST tests expect exactly that (writes default to
	// `Prefer: return=minimal`), and encoding it as `Expected: ""` silently
	// degraded those tests to status-only checks.
	ExpectedEmpty   bool
	ExpectedHeaders map[string]string
	Status          int
}

We don't embed Command to simplify tests writing

Jump to

Keyboard shortcuts

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