Documentation
¶
Index ¶
- func AssertContains(container interface{}, element interface{}) bool
- func AssertEqual(actual, expected interface{}) bool
- func AssertJSONEqual(actual, expected string) bool
- func AssertMatch(value string, pattern string) bool
- func FormatTestResults(results []TestResult) string
- type ConsoleHandler
- type Engine
- func (e *Engine) Clone() *Engine
- func (e *Engine) Execute(ctx context.Context, script string) (interface{}, error)
- func (e *Engine) ExecuteWithTimeout(script string, timeout time.Duration) (interface{}, error)
- func (e *Engine) GetGlobal(name string) interface{}
- func (e *Engine) RegisterFunction(name string, fn interface{})
- func (e *Engine) RegisterObject(name string, obj map[string]interface{})
- func (e *Engine) Reset()
- func (e *Engine) SetConsoleHandler(handler ConsoleHandler)
- func (e *Engine) SetGlobal(name string, value interface{})
- type LogHandler
- type RequestSender
- type SandboxedEngine
- func (e *SandboxedEngine) DisableEval()
- func (e *SandboxedEngine) Execute(ctx context.Context, script string) (interface{}, error)
- func (e *SandboxedEngine) RegisterFunction(name string, fn interface{})
- func (e *SandboxedEngine) RegisterObject(name string, obj map[string]interface{})
- func (e *SandboxedEngine) SetConsoleHandler(handler func(level, msg string))
- func (e *SandboxedEngine) SetGlobal(name string, value interface{})
- func (e *SandboxedEngine) SetIterationLimit(limit int64)
- func (e *SandboxedEngine) SetMemoryLimit(limit int64)
- type SandboxedScope
- type Scope
- func (s *Scope) Clone() *Scope
- func (s *Scope) Engine() *Engine
- func (s *Scope) Execute(ctx context.Context, script string) (interface{}, error)
- func (s *Scope) GetEnvironmentVariable(key string) string
- func (s *Scope) GetRequestBody() string
- func (s *Scope) GetRequestHeaders() map[string]string
- func (s *Scope) GetRequestURL() string
- func (s *Scope) GetVariable(key string) string
- func (s *Scope) Reset()
- func (s *Scope) SetEnvironmentName(name string)
- func (s *Scope) SetEnvironmentVariable(key, value string)
- func (s *Scope) SetLogHandler(handler LogHandler)
- func (s *Scope) SetRequestBody(body string)
- func (s *Scope) SetRequestHeaders(headers map[string]string)
- func (s *Scope) SetRequestMethod(method string)
- func (s *Scope) SetRequestSender(sender RequestSender)
- func (s *Scope) SetRequestURL(url string)
- func (s *Scope) SetResponseBody(body string)
- func (s *Scope) SetResponseHeaders(headers map[string]string)
- func (s *Scope) SetResponseSize(size int64)
- func (s *Scope) SetResponseStatus(status int)
- func (s *Scope) SetResponseStatusText(text string)
- func (s *Scope) SetResponseTime(time int64)
- func (s *Scope) SetVariable(key, value string)
- type ScopeWithAssertions
- func (s *ScopeWithAssertions) AllTestsPassed() bool
- func (s *ScopeWithAssertions) ClearTestResults()
- func (s *ScopeWithAssertions) Execute(ctx context.Context, script string) (interface{}, error)
- func (s *ScopeWithAssertions) GetTestResults() []TestResult
- func (s *ScopeWithAssertions) GetTestSummary() TestSummary
- type TestResult
- type TestSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContains ¶
func AssertContains(container interface{}, element interface{}) bool
AssertContains checks if a string contains a substring or an array contains an element.
func AssertEqual ¶
func AssertEqual(actual, expected interface{}) bool
AssertEqual checks if two values are equal.
func AssertJSONEqual ¶
AssertJSONEqual checks if two JSON strings represent equal values.
func AssertMatch ¶
AssertMatch checks if a string matches a regex pattern.
func FormatTestResults ¶
func FormatTestResults(results []TestResult) string
FormatTestResults formats test results for display.
Types ¶
type ConsoleHandler ¶
type ConsoleHandler func(level, message string)
ConsoleHandler is a function that handles console output from JavaScript.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine wraps the Goja JavaScript runtime for executing scripts.
func (*Engine) ExecuteWithTimeout ¶
ExecuteWithTimeout executes a script with a specific timeout.
func (*Engine) RegisterFunction ¶
RegisterFunction registers a Go function to be callable from JavaScript.
func (*Engine) RegisterObject ¶
RegisterObject registers an object with properties/methods accessible from JavaScript.
func (*Engine) Reset ¶
func (e *Engine) Reset()
Reset clears the engine state and creates a fresh runtime.
func (*Engine) SetConsoleHandler ¶
func (e *Engine) SetConsoleHandler(handler ConsoleHandler)
SetConsoleHandler sets the handler for console output.
type LogHandler ¶
type LogHandler func(message string)
LogHandler is a function that handles log output from scripts.
type RequestSender ¶
RequestSender is a function that sends an HTTP request from within a script.
type SandboxedEngine ¶
type SandboxedEngine struct {
// contains filtered or unexported fields
}
SandboxedEngine provides a secure JavaScript execution environment.
func NewSandboxedEngine ¶
func NewSandboxedEngine() *SandboxedEngine
NewSandboxedEngine creates a new sandboxed JavaScript engine.
func (*SandboxedEngine) DisableEval ¶
func (e *SandboxedEngine) DisableEval()
DisableEval disables eval() and Function constructor.
func (*SandboxedEngine) Execute ¶
func (e *SandboxedEngine) Execute(ctx context.Context, script string) (interface{}, error)
Execute runs JavaScript code in the sandbox.
func (*SandboxedEngine) RegisterFunction ¶
func (e *SandboxedEngine) RegisterFunction(name string, fn interface{})
RegisterFunction registers a Go function callable from JavaScript.
func (*SandboxedEngine) RegisterObject ¶
func (e *SandboxedEngine) RegisterObject(name string, obj map[string]interface{})
RegisterObject registers a Go object as a JavaScript global.
func (*SandboxedEngine) SetConsoleHandler ¶
func (e *SandboxedEngine) SetConsoleHandler(handler func(level, msg string))
SetConsoleHandler sets the handler for console output.
func (*SandboxedEngine) SetGlobal ¶
func (e *SandboxedEngine) SetGlobal(name string, value interface{})
SetGlobal sets a global variable in the sandbox.
func (*SandboxedEngine) SetIterationLimit ¶
func (e *SandboxedEngine) SetIterationLimit(limit int64)
SetIterationLimit sets the maximum number of loop iterations.
func (*SandboxedEngine) SetMemoryLimit ¶
func (e *SandboxedEngine) SetMemoryLimit(limit int64)
SetMemoryLimit sets the memory limit (note: not strictly enforced by Goja).
type SandboxedScope ¶
type SandboxedScope struct {
*ScopeWithAssertions
// contains filtered or unexported fields
}
SandboxedScope extends ScopeWithAssertions with sandbox protection.
func NewSandboxedScope ¶
func NewSandboxedScope() *SandboxedScope
NewSandboxedScope creates a new scope with sandbox protection.
func (*SandboxedScope) DisableEval ¶
func (s *SandboxedScope) DisableEval()
DisableEval disables eval in the sandbox.
func (*SandboxedScope) Execute ¶
func (s *SandboxedScope) Execute(ctx context.Context, script string) (interface{}, error)
Execute runs a script in the sandboxed scope.
func (*SandboxedScope) SetIterationLimit ¶
func (s *SandboxedScope) SetIterationLimit(limit int64)
SetIterationLimit sets the iteration limit for the sandbox.
func (*SandboxedScope) SetSandboxConsoleHandler ¶
func (s *SandboxedScope) SetSandboxConsoleHandler(handler func(level, msg string))
SetSandboxConsoleHandler sets the console handler for the sandbox.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope provides the execution context for scripts with the currier.* API.
func (*Scope) GetEnvironmentVariable ¶
GetEnvironmentVariable gets an environment variable.
func (*Scope) GetRequestBody ¶
GetRequestBody gets the request body.
func (*Scope) GetRequestHeaders ¶
GetRequestHeaders gets the request headers.
func (*Scope) GetRequestURL ¶
GetRequestURL gets the request URL.
func (*Scope) GetVariable ¶
GetVariable gets a variable value.
func (*Scope) SetEnvironmentName ¶
SetEnvironmentName sets the environment name.
func (*Scope) SetEnvironmentVariable ¶
SetEnvironmentVariable sets an environment variable.
func (*Scope) SetLogHandler ¶
func (s *Scope) SetLogHandler(handler LogHandler)
SetLogHandler sets the handler for log output.
func (*Scope) SetRequestBody ¶
SetRequestBody sets the request body.
func (*Scope) SetRequestHeaders ¶
SetRequestHeaders sets the request headers.
func (*Scope) SetRequestMethod ¶
SetRequestMethod sets the request method.
func (*Scope) SetRequestSender ¶
func (s *Scope) SetRequestSender(sender RequestSender)
SetRequestSender sets the function for sending requests from scripts.
func (*Scope) SetRequestURL ¶
SetRequestURL sets the request URL.
func (*Scope) SetResponseBody ¶
SetResponseBody sets the response body.
func (*Scope) SetResponseHeaders ¶
SetResponseHeaders sets the response headers.
func (*Scope) SetResponseSize ¶
SetResponseSize sets the response size in bytes.
func (*Scope) SetResponseStatus ¶
SetResponseStatus sets the response status code.
func (*Scope) SetResponseStatusText ¶
SetResponseStatusText sets the response status text.
func (*Scope) SetResponseTime ¶
SetResponseTime sets the response time in milliseconds.
func (*Scope) SetVariable ¶
SetVariable sets a variable.
type ScopeWithAssertions ¶
type ScopeWithAssertions struct {
*Scope
// contains filtered or unexported fields
}
ScopeWithAssertions extends Scope with test assertion capabilities.
func NewScopeWithAssertions ¶
func NewScopeWithAssertions() *ScopeWithAssertions
NewScopeWithAssertions creates a new scope with assertion capabilities.
func (*ScopeWithAssertions) AllTestsPassed ¶
func (s *ScopeWithAssertions) AllTestsPassed() bool
AllTestsPassed returns true if all tests passed.
func (*ScopeWithAssertions) ClearTestResults ¶
func (s *ScopeWithAssertions) ClearTestResults()
ClearTestResults clears all test results.
func (*ScopeWithAssertions) Execute ¶
func (s *ScopeWithAssertions) Execute(ctx context.Context, script string) (interface{}, error)
Execute runs a script in this scope with assertion support.
func (*ScopeWithAssertions) GetTestResults ¶
func (s *ScopeWithAssertions) GetTestResults() []TestResult
GetTestResults returns all test results.
func (*ScopeWithAssertions) GetTestSummary ¶
func (s *ScopeWithAssertions) GetTestSummary() TestSummary
GetTestSummary returns aggregate test statistics.
type TestResult ¶
TestResult represents the result of a single test.
type TestSummary ¶
TestSummary provides aggregate test statistics.