Documentation
¶
Index ¶
- func RegisterSharedSteps(ctx *godog.ScenarioContext, shared *SharedContext)
- type SharedBridge
- type SharedContext
- func (c *SharedContext) AFileShouldExist(path string) error
- func (c *SharedContext) CaptureErrorOutput(output string)
- func (c *SharedContext) CaptureHTTPResponse(w io.Writer)
- func (c *SharedContext) CaptureOutput(output string)
- func (c *SharedContext) Cleanup()
- func (c *SharedContext) IHaveACleanDatabase() error
- func (c *SharedContext) IHaveAWorkingDirectory(dir string) error
- func (c *SharedContext) IRenderHTMLContaining(html string) error
- func (c *SharedContext) IRunCommand(command string) error
- func (c *SharedContext) IRunCommandWithTimeout(command string, timeoutSeconds int) error
- func (c *SharedContext) ISetEnvironmentVariable(key, value string) error
- func (c *SharedContext) ISubmitAPostRequestTo(path string) error
- func (c *SharedContext) IVisit(path string) error
- func (c *SharedContext) Reset()
- func (c *SharedContext) SetHTTPApp(app *buffalo.App)
- func (c *SharedContext) TheContentTypeShouldBe(expected string) error
- func (c *SharedContext) TheErrorOutputShouldContain(expected string) error
- func (c *SharedContext) TheExitCodeShouldBe(expected int) error
- func (c *SharedContext) TheFileShouldContain(path, expected string) error
- func (c *SharedContext) TheMigrationsTableShouldExist() error
- func (c *SharedContext) TheOutputShouldContain(expected string) error
- func (c *SharedContext) TheOutputShouldMatch(pattern string) error
- func (c *SharedContext) TheOutputShouldNotContain(unexpected string) error
- func (c *SharedContext) TheResponseStatusShouldBe(expected int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterSharedSteps ¶
func RegisterSharedSteps(ctx *godog.ScenarioContext, shared *SharedContext)
RegisterSharedSteps registers all shared step definitions with godog
Types ¶
type SharedBridge ¶
type SharedBridge struct {
// contains filtered or unexported fields
}
SharedBridge provides a way to use the shared context alongside existing test suites without breaking their existing implementations
func NewSharedBridge ¶
func NewSharedBridge() *SharedBridge
NewSharedBridge creates a new bridge with shared context
func (*SharedBridge) GetSharedContext ¶
func (b *SharedBridge) GetSharedContext() *SharedContext
GetSharedContext returns the underlying shared context for direct access if needed
func (*SharedBridge) RegisterBridgedSteps ¶
func (b *SharedBridge) RegisterBridgedSteps(ctx *godog.ScenarioContext)
RegisterBridgedSteps registers shared steps that can work alongside existing implementations This allows gradual migration and doesn't break existing tests
type SharedContext ¶
type SharedContext struct {
// Output from any operation (HTML rendering, CLI commands, HTTP responses, etc.)
// HTTP testing
// CLI command execution
// Database for testing
ComponentRegistry *components.Registry
// Component testing
CleanupFuncs []func()
}
SharedContext provides common test functionality for all test suites
func NewSharedContext ¶
func NewSharedContext() *SharedContext
NewSharedContext creates a new shared test context
func (*SharedContext) AFileShouldExist ¶
func (c *SharedContext) AFileShouldExist(path string) error
AFileShouldExist checks if a file exists
func (*SharedContext) CaptureErrorOutput ¶
func (c *SharedContext) CaptureErrorOutput(output string)
CaptureErrorOutput sets the error output directly
func (*SharedContext) CaptureHTTPResponse ¶
func (c *SharedContext) CaptureHTTPResponse(w io.Writer)
CaptureHTTPResponse captures an HTTP response for testing
func (*SharedContext) CaptureOutput ¶
func (c *SharedContext) CaptureOutput(output string)
CaptureOutput sets the output directly (for integration with existing tests)
func (*SharedContext) Cleanup ¶
func (c *SharedContext) Cleanup()
Cleanup runs all cleanup functions
func (*SharedContext) IHaveACleanDatabase ¶
func (c *SharedContext) IHaveACleanDatabase() error
IHaveACleanDatabase sets up a fresh test database
func (*SharedContext) IHaveAWorkingDirectory ¶
func (c *SharedContext) IHaveAWorkingDirectory(dir string) error
IHaveAWorkingDirectory sets the working directory for commands
func (*SharedContext) IRenderHTMLContaining ¶
func (c *SharedContext) IRenderHTMLContaining(html string) error
IRenderHTMLContaining simulates rendering HTML (usually through a component system)
func (*SharedContext) IRunCommand ¶
func (c *SharedContext) IRunCommand(command string) error
IRunCommand executes a CLI command
func (*SharedContext) IRunCommandWithTimeout ¶
func (c *SharedContext) IRunCommandWithTimeout(command string, timeoutSeconds int) error
IRunCommandWithTimeout executes a CLI command with a timeout in seconds
func (*SharedContext) ISetEnvironmentVariable ¶
func (c *SharedContext) ISetEnvironmentVariable(key, value string) error
ISetEnvironmentVariable sets an environment variable for command execution
func (*SharedContext) ISubmitAPostRequestTo ¶
func (c *SharedContext) ISubmitAPostRequestTo(path string) error
ISubmitAPostRequestTo makes an HTTP POST request
func (*SharedContext) IVisit ¶
func (c *SharedContext) IVisit(path string) error
IVisit makes an HTTP GET request to a path
func (*SharedContext) Reset ¶
func (c *SharedContext) Reset()
Reset clears the context for a new scenario
func (*SharedContext) SetHTTPApp ¶
func (c *SharedContext) SetHTTPApp(app *buffalo.App)
SetHTTPApp sets the Buffalo app for HTTP testing
func (*SharedContext) TheContentTypeShouldBe ¶
func (c *SharedContext) TheContentTypeShouldBe(expected string) error
TheContentTypeShouldBe checks the response content type
func (*SharedContext) TheErrorOutputShouldContain ¶
func (c *SharedContext) TheErrorOutputShouldContain(expected string) error
TheErrorOutputShouldContain specifically checks error output
func (*SharedContext) TheExitCodeShouldBe ¶
func (c *SharedContext) TheExitCodeShouldBe(expected int) error
TheExitCodeShouldBe checks the command exit code
func (*SharedContext) TheFileShouldContain ¶
func (c *SharedContext) TheFileShouldContain(path, expected string) error
TheFileShouldContain checks if a file contains expected text
func (*SharedContext) TheMigrationsTableShouldExist ¶
func (c *SharedContext) TheMigrationsTableShouldExist() error
TheMigrationsTableShouldExist checks if migrations table was created
func (*SharedContext) TheOutputShouldContain ¶
func (c *SharedContext) TheOutputShouldContain(expected string) error
TheOutputShouldContain checks if any output contains the expected text This handles: standard output, error output, HTTP response body, rendered HTML
func (*SharedContext) TheOutputShouldMatch ¶
func (c *SharedContext) TheOutputShouldMatch(pattern string) error
TheOutputShouldMatch checks if output matches a regex pattern
func (*SharedContext) TheOutputShouldNotContain ¶
func (c *SharedContext) TheOutputShouldNotContain(unexpected string) error
TheOutputShouldNotContain checks that no output contains the unexpected text
func (*SharedContext) TheResponseStatusShouldBe ¶
func (c *SharedContext) TheResponseStatusShouldBe(expected int) error
TheResponseStatusShouldBe checks the HTTP response status code