Movatterモバイル変換


[0]ホーム

URL:


Alert GO-2024-3228: Coder vulnerable to post-auth URL redirection to untrusted site ('Open Redirect') in github.com/coder/coder
Notice  The highest tagged major version isv2.

harness

package
v0.27.3Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License:AGPL-3.0Imports:15Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeCleanable

type Cleanable interface {Runnable// Cleanup should clean up any lingering resources from the test.Cleanup(ctxcontext.Context, idstring)error}

Cleanable is an optional extension to Runnable that allows for post-testcleanup.

typeConcurrentExecutionStrategy

type ConcurrentExecutionStrategy struct{}

ConcurrentExecutionStrategy executes all test runs concurrently without anyregard for parallelism.

func (ConcurrentExecutionStrategy)Run

Run implements ExecutionStrategy.

typeExecutionStrategy

type ExecutionStrategy interface {// Execute calls each function in whatever way the strategy wants. All// errors returned from the function should be wrapped and returned, but all// given functions must be executed.Run(ctxcontext.Context, fns []TestFn) ([]error,error)}

ExecutionStrategy defines how a TestHarness should execute a set of runs. Itessentially defines the concurrency model for a given testing session.

typeLinearExecutionStrategy

type LinearExecutionStrategy struct{}

LinearExecutionStrategy executes all test runs in a linear fashion, one afterthe other.

func (LinearExecutionStrategy)Run

Run implements ExecutionStrategy.

typeParallelExecutionStrategy

type ParallelExecutionStrategy struct {Limitint}

ParallelExecutionStrategy executes all test runs concurrently, but limits thenumber of concurrent runs to the given limit.

func (ParallelExecutionStrategy)Run

Run implements ExecutionStrategy.

typeResults

type Results struct {TotalRunsint              `json:"total_runs"`TotalPassint              `json:"total_pass"`TotalFailint              `json:"total_fail"`Elapsedhttpapi.Duration `json:"elapsed"`ElapsedMSint64            `json:"elapsed_ms"`Runs map[string]RunResult `json:"runs"`}

Results is the full compiled results for a set of test runs.

func (*Results)PrintText

func (r *Results) PrintText(wio.Writer)

PrintText prints the results as human-readable text to the given writer.

typeRunResult

type RunResult struct {FullIDstring           `json:"full_id"`TestNamestring           `json:"test_name"`IDstring           `json:"id"`Logsstring           `json:"logs"`Errorerror            `json:"error"`StartedAttime.Time        `json:"started_at"`Durationhttpapi.Duration `json:"duration"`DurationMSint64            `json:"duration_ms"`}

RunResult is the result of a single test run.

typeRunnable

type Runnable interface {// Run should use the passed context to handle cancellation and deadlines// properly, and should only return once the test has been fully completed// (no lingering goroutines, unless they are cleaned up by the accompanying// cleanup function).//// The test ID (part after the slash) is passed for identification if// necessary, and the provided logs write should be used for writing// whatever may be necessary for debugging the test.Run(ctxcontext.Context, idstring, logsio.Writer)error}

Runnable is a test interface that can be executed by a TestHarness.

typeShuffleExecutionStrategyWrapper

type ShuffleExecutionStrategyWrapper struct {InnerExecutionStrategy}

ShuffleExecutionStrategyWrapper is an ExecutionStrategy that wraps anotherExecutionStrategy and shuffles the order of the test runs before executing.

func (ShuffleExecutionStrategyWrapper)Run

Run implements ExecutionStrategy.

typeTestFn

type TestFn func(ctxcontext.Context)error

TestFn is a function that can be run by an ExecutionStrategy.

typeTestHarness

type TestHarness struct {// contains filtered or unexported fields}

TestHarness runs a bunch of registered test runs using the given executionstrategies.

funcNewTestHarness

func NewTestHarness(runStrategy, cleanupStrategyExecutionStrategy) *TestHarness

NewTestHarness creates a new TestHarness with the given execution strategies.

func (*TestHarness)AddRun

func (h *TestHarness) AddRun(testNamestring, idstring, runnerRunnable) *TestRun

AddRun creates a new *TestRun with the given name, ID and Runnable, adds itto the harness and returns it. Panics if the harness has been started, or atest with the given run.FullID() is already registered.

This is a convenience method that calls NewTestRun() and h.RegisterRun().

func (*TestHarness)Cleanup

func (h *TestHarness) Cleanup(ctxcontext.Context) (errerror)

Cleanup should be called after the test run has finished and results havebeen collected.

func (*TestHarness)RegisterRun

func (h *TestHarness) RegisterRun(run *TestRun)

RegisterRun registers the given *TestRun with the harness. Panics if theharness has been started, or a test with the given run.FullID() is alreadyregistered.

func (*TestHarness)Results

func (h *TestHarness) Results()Results

Results collates the results of all the test runs and returns them.

func (*TestHarness)Run

func (h *TestHarness) Run(ctxcontext.Context) (errerror)

Run runs the registered tests using the given ExecutionStrategy. The providedcontext can be used to cancel or set a deadline for the test run. Blocksuntil the tests have finished and returns the test execution error (notindividual run errors).

Panics if called more than once.

typeTestRun

type TestRun struct {// contains filtered or unexported fields}

TestRun is a single test run and it's accompanying state.

funcNewTestRun

func NewTestRun(testNamestring, idstring, runnerRunnable) *TestRun

func (*TestRun)Cleanup

func (r *TestRun) Cleanup(ctxcontext.Context) (errerror)

func (*TestRun)FullID

func (r *TestRun) FullID()string

func (*TestRun)Result

func (r *TestRun) Result()RunResult

Results returns the results of the test run. Panics if the test run is notdone yet.

func (*TestRun)Run

func (r *TestRun) Run(ctxcontext.Context) (errerror)

Run executes the Run function with a self-managed log writer, panic handler,error recording and duration recording. The test error is returned.

typeTimeoutExecutionStrategyWrapper

type TimeoutExecutionStrategyWrapper struct {Timeouttime.DurationInnerExecutionStrategy}

TimeoutExecutionStrategyWrapper is an ExecutionStrategy that wraps anotherExecutionStrategy and applies a timeout to each test run's context.

func (TimeoutExecutionStrategyWrapper)Run

Run implements ExecutionStrategy.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp