testing

package
v0.0.0-...-0b99702 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAuth

func ApplyAuth(req *http.Request, auth *models.AuthConfig)

applyAuth applies authentication configuration to an HTTP request

func BuildQueryParams

func BuildQueryParams(operation *openapi3.Operation) string

buildQueryParams constructs query parameters from operation parameters

func ExecuteCustomRequest

func ExecuteCustomRequest(method, endpoint string, headers map[string]string, body string, auth *models.AuthConfig, verbose bool) (models.TestResult, error)

ExecuteCustomRequest executes a manually created API request

func ExecuteCustomRequestCmd

func ExecuteCustomRequestCmd(method, endpoint string, headers map[string]string, body string, auth *models.AuthConfig, verbose bool) tea.Cmd

ExecuteCustomRequestCmd wraps ExecuteCustomRequest as a Bubble Tea command

func FormatJSONBody

func FormatJSONBody(body string) (string, error)

FormatJSONBody formats a JSON string with indentation

func GenerateRequestBody

func GenerateRequestBody(operation *openapi3.Operation) ([]byte, error)

generateRequestBody creates a sample JSON request body from an OpenAPI schema Generates realistic sample data based on schema properties, types, and examples

func GenerateSampleFromSchema

func GenerateSampleFromSchema(schema *openapi3.Schema) interface{}

generateSampleFromSchema recursively generates sample data from an OpenAPI schema

func ReplacePlaceholders

func ReplacePlaceholders(path string) string

replacePlaceholders replaces path parameters like {id} with sample values

func RunTestCmd

func RunTestCmd(specPath, baseURL string, auth *models.AuthConfig, verbose bool, maxRetries int, retryDelay int) tea.Cmd

runTestCmd wraps runTests in a Bubble Tea command Returns a message containing test results or error

func RunTestParallelCmd

func RunTestParallelCmd(specPath, baseURL string, auth *models.AuthConfig, verbose bool, maxConcurrency int, maxRetries int, retryDelay int) tea.Cmd

RunTestParallelCmd wraps RunTestsParallel in a Bubble Tea command Uses same interface as RunTestCmd for easy migration

func RunTestParallelCmdWithSelection

func RunTestParallelCmdWithSelection(specPath, baseURL string, auth *models.AuthConfig, verbose bool, maxConcurrency int, maxRetries int, retryDelay int, selectedEndpoints []models.EndpointInfo) tea.Cmd

RunTestParallelCmdWithSelection executes tests for only selected endpoints

func RunTests

func RunTests(specPath, baseURL string, auth *models.AuthConfig, verbose bool, maxRetries int, retryDelay int) ([]models.TestResult, error)

runTests executes API tests against endpoints defined in OpenAPI spec Tests each endpoint with a simple request and records results Accepts optional auth configuration, verbose flag, and retry configuration

func RunTestsParallel

func RunTestsParallel(specPath, baseURL string, auth *models.AuthConfig, verbose bool, maxConcurrency int, maxRetries int, retryDelay int, progressChan chan<- tea.Msg) ([]models.TestResult, error)

RunTestsParallel executes API tests concurrently with a worker pool maxConcurrency: maximum number of concurrent requests (0 = auto-detect)

func RunTestsParallelWithSelection

func RunTestsParallelWithSelection(specPath, baseURL string, auth *models.AuthConfig, verbose bool, maxConcurrency int, maxRetries int, retryDelay int, progressChan chan<- tea.Msg, selectedEndpoints []models.EndpointInfo) ([]models.TestResult, error)

RunTestsParallelWithSelection runs tests for only the selected endpoints

func TestEndpoint

func TestEndpoint(method, url string, body []byte, auth *models.AuthConfig, verbose bool) (int, *http.Response, *models.LogEntry, error)

testEndpoint performs an HTTP request to test an API endpoint Supports GET, POST, PUT, PATCH, DELETE methods with optional request bodies Returns status code, response object, log entry, and error

func TestEndpointWithRetry

func TestEndpointWithRetry(
	method, url string,
	body []byte,
	auth *models.AuthConfig,
	verbose bool,
	maxRetries int,
	retryDelay int,
) (int, *http.Response, *models.LogEntry, int, error)

TestEndpointWithRetry is a wrapper around executeWithRetry that returns the standard TestEndpoint signature plus the retry count for tracking

func ValidateJSONBody

func ValidateJSONBody(body string) error

ValidateJSONBody validates that a string is valid JSON

Types

type TestCompleteMsg

type TestCompleteMsg struct {
	Results []models.TestResult
}

TestCompleteMsg is sent when testing completes successfully

type TestErrorMsg

type TestErrorMsg struct {
	Err error
}

TestErrorMsg is sent when testing encounters an error

type TestJob

type TestJob struct {
	Method      string
	Path        string
	Endpoint    string
	RequestBody []byte
	Operation   *openapi3.Operation
}

TestJob represents a single test to execute

type TestProgressMsg

type TestProgressMsg struct {
	Completed int
	Total     int
	Latest    *models.TestResult // Most recent result
}

TestProgressMsg is sent during parallel execution to update progress

Jump to

Keyboard shortcuts

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