Documentation
¶
Index ¶
- func FindFreePort(t *testing.T) int
- func RunCmd(t *testing.T, args []string, env []string) (string, func())
- func StartServer(t *testing.T, port int, schemaFile string, extraArgs ...string) (*exec.Cmd, <-chan error, int)
- func StopServer(t *testing.T, cmd *exec.Cmd)
- func WaitForServer(t *testing.T, port int, timeout time.Duration) bool
- type ServerBuilder
- func (b *ServerBuilder) AddArg(arg string) *ServerBuilder
- func (b *ServerBuilder) DisableCORS(disable bool) *ServerBuilder
- func (b *ServerBuilder) DisableControlAPI(disable bool) *ServerBuilder
- func (b *ServerBuilder) Run() (*exec.Cmd, <-chan error, int)
- func (b *ServerBuilder) SetDelay(milliseconds int) *ServerBuilder
- func (b *ServerBuilder) SetEnv(env []string) *ServerBuilder
- func (b *ServerBuilder) SetHistorySize(size int) *ServerBuilder
- func (b *ServerBuilder) SetPort(port int) *ServerBuilder
- func (b *ServerBuilder) SetSchema(schema string, prefix string) *ServerBuilder
- func (b *ServerBuilder) SetVerbose(verbose bool) *ServerBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindFreePort ¶
FindFreePort finds and returns a free TCP port. Deprecated: Use Cmd(t).SetPort(0).Run() instead.
func RunCmd ¶
RunCmd executes a CLI command with optional environment variables. Returns the combined output (stdout+stderr) and a cleanup function to kill the process.
func StartServer ¶
func StartServer(t *testing.T, port int, schemaFile string, extraArgs ...string) (*exec.Cmd, <-chan error, int)
StartServer starts the oasmock CLI server as a subprocess. Returns the command, an error channel that will receive the exit error, and the actual port used. Deprecated: Use Cmd(t).SetSchema(schemaFile, "").SetPort(port).AddArg(extraArgs...).Run() instead.
func StopServer ¶
StopServer stops the CLI server process.
Types ¶
type ServerBuilder ¶
type ServerBuilder struct {
// contains filtered or unexported fields
}
ServerBuilder provides a fluent interface for configuring and starting an oasmock server. No validation is performed - invalid configurations will be caught by the CLI.
func Cmd ¶
func Cmd(t *testing.T) *ServerBuilder
Cmd creates a new ServerBuilder for configuring an oasmock server.
func (*ServerBuilder) AddArg ¶
func (b *ServerBuilder) AddArg(arg string) *ServerBuilder
AddArg adds a raw CLI argument for advanced configuration.
func (*ServerBuilder) DisableCORS ¶
func (b *ServerBuilder) DisableCORS(disable bool) *ServerBuilder
DisableCORS enables or disables CORS headers.
func (*ServerBuilder) DisableControlAPI ¶
func (b *ServerBuilder) DisableControlAPI(disable bool) *ServerBuilder
DisableControlAPI enables or disables the management control API.
func (*ServerBuilder) Run ¶
func (b *ServerBuilder) Run() (*exec.Cmd, <-chan error, int)
Run starts the configured oasmock server and returns the command, error channel, and actual port used (useful when port=0).
func (*ServerBuilder) SetDelay ¶
func (b *ServerBuilder) SetDelay(milliseconds int) *ServerBuilder
SetDelay sets the delay between request and response in milliseconds.
func (*ServerBuilder) SetEnv ¶
func (b *ServerBuilder) SetEnv(env []string) *ServerBuilder
SetEnv sets environment variables for the server process.
func (*ServerBuilder) SetHistorySize ¶
func (b *ServerBuilder) SetHistorySize(size int) *ServerBuilder
SetHistorySize sets the maximum number of requests to keep in history.
func (*ServerBuilder) SetPort ¶
func (b *ServerBuilder) SetPort(port int) *ServerBuilder
SetPort sets the port to listen on. Use 0 to auto-find a free port.
func (*ServerBuilder) SetSchema ¶
func (b *ServerBuilder) SetSchema(schema string, prefix string) *ServerBuilder
SetSchema adds a schema file with an optional prefix. Can be called multiple times to add multiple schemas.
func (*ServerBuilder) SetVerbose ¶
func (b *ServerBuilder) SetVerbose(verbose bool) *ServerBuilder
SetVerbose enables or disables verbose logging.