test

package
v0.2.54 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertRequestResult

func AssertRequestResult(t *testing.T, actual *task.Result, actualErr error, expected *task.Result, expectedErr error)

AssertRequestResult compares the actual and expected results of a task in a testing context.

func ConveyTest

func ConveyTest(t *testing.T, tests []ExecutorTest)

ConveyTest executes the executor tests using Convey from goconvey.

func NewMockHttpClient

func NewMockHttpClient(mocks []MockResult) rest.HTTPClient

NewMockHttpClient creates a new instance of MockHttpClient based on the provided mock results.

func TestConnection added in v0.2.40

func TestConnection(tester ConnectionTester) (*task.Result, error)

TestConnection performs a connection test using the provided ConnectionTester.

It returns a task.Result containing the JSON representation of the TestConnectionResult. If the connection test encounters an error, the 'Success' field is set to false, and the 'Output' field contains the error message.

Types

type ConnectionTester added in v0.2.40

type ConnectionTester interface {
	TestConnection() error
}

ConnectionTester is an interface for testing connections.

Implementations should provide the TestConnection method for conducting the actual connection test.

type ExecutorTest

type ExecutorTest struct {
	ExecutorTestConfig
	Input    []byte
	Expected []byte
	// contains filtered or unexported fields
}

ExecutorTest represents an executor test case.

func CreateExecutorTest

func CreateExecutorTest(path string) *ExecutorTest

CreateExecutorTest creates a new executor test case.

func CreateExecutorTestSet

func CreateExecutorTestSet(basePath string, tests map[string]runner.Runner) []ExecutorTest

CreateExecutorTestSet creates a set of executor tests based on the specified base path and runners.

func (*ExecutorTest) Build

func (fixture *ExecutorTest) Build() (*ExecutorTest, error)

Build creates the executor test case.

func (ExecutorTest) GetInputFilepath

func (fixture ExecutorTest) GetInputFilepath() string

GetInputFilepath returns the file path of the input file.

func (ExecutorTest) GetOutputFilepath

func (fixture ExecutorTest) GetOutputFilepath() string

GetOutputFilepath returns the file path of the output file.

func (ExecutorTest) LoadOutputResult

func (fixture ExecutorTest) LoadOutputResult() ([]byte, error)

LoadOutputResult loads the output result from the test case.

func (*ExecutorTest) WithAssert

func (fixture *ExecutorTest) WithAssert(assert convey.Assertion) *ExecutorTest

WithAssert adds an assertion for the executor test.

func (*ExecutorTest) WithExpectedOutputFile

func (fixture *ExecutorTest) WithExpectedOutputFile(filename string) *ExecutorTest

WithExpectedOutputFile sets the expected output file name for the executor test.

func (*ExecutorTest) WithInputFile

func (fixture *ExecutorTest) WithInputFile(filename string) *ExecutorTest

WithInputFile sets the input file name for the executor test.

func (*ExecutorTest) WithOutputFile

func (fixture *ExecutorTest) WithOutputFile(filename string) *ExecutorTest

WithOutputFile sets the output file name for the executor test.

func (*ExecutorTest) WithRunnerFunction

func (fixture *ExecutorTest) WithRunnerFunction(function runner.Runner) *ExecutorTest

WithRunnerFunction sets the runner function for the executor test.

type ExecutorTestConfig

type ExecutorTestConfig struct {
	Runner runner.Runner
	// contains filtered or unexported fields
}

ExecutorTestConfig holds the configuration for an executor test.

type MockBody

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

MockBody is a mock implementation of the http.Response.Body interface.

func (*MockBody) Close

func (b *MockBody) Close() error

Close resets the offset of the mock response body.

func (*MockBody) Read

func (b *MockBody) Read(p []byte) (int, error)

Read reads data from the mock response body.

type MockHttpClient

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

MockHttpClient is a mock implementation of the rest.HTTPClient interface.

func (MockHttpClient) Do

func (c MockHttpClient) Do(req *http.Request) (*http.Response, error)

Do performs the mock HTTP request.

type MockResult

type MockResult struct {
	Method     string
	Path       string
	Filename   string
	Data       []byte
	StatusCode int
}

MockResult represents a mocked HTTP response.

type TestConnectionResult added in v0.2.40

type TestConnectionResult struct {
	Success bool   `json:"success"`
	Output  string `json:"output"`
}

TestConnectionResult represents the result of a connection test.

It includes a boolean flag 'Success' indicating whether the test was successful, and a string 'Output' containing additional information or error message.

Jump to

Keyboard shortcuts

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