tests

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertJSONResponse

func AssertJSONResponse(t *testing.T, resp *http.Response, expectedFields map[string]interface{})

AssertJSONResponse checks if response contains expected JSON fields

func AssertNoError

func AssertNoError(t *testing.T, err error)

AssertNoError checks that error is nil

func AssertResponseContains

func AssertResponseContains(t *testing.T, resp *http.Response, expected string)

AssertResponseContains checks if response body contains expected string

func AssertStatus

func AssertStatus(t *testing.T, expected, actual int)

AssertStatus checks if the response has the expected status code

func RunTestScenarios

func RunTestScenarios(t *testing.T, ts *TestServer, scenarios []TestScenario)

RunTestScenarios runs multiple test scenarios

func WaitForCondition

func WaitForCondition(t *testing.T, condition func() bool, timeout time.Duration, message string)

WaitForCondition waits for a condition to be true

Types

type MockRequest

type MockRequest struct {
	Method  string
	Path    string
	Headers map[string]string
	Body    interface{}
}

MockRequest creates a mock HTTP request for testing

func (*MockRequest) ToHTTPRequest

func (mr *MockRequest) ToHTTPRequest() (*http.Request, error)

ToHTTPRequest converts MockRequest to http.Request

type TestScenario

type TestScenario struct {
	Name           string
	Request        MockRequest
	ExpectedStatus int
	ExpectedFields map[string]interface{}
	ExpectedError  bool
}

TestScenario represents a test scenario

type TestServer

type TestServer struct {
	Server *httptest.Server
	Client *http.Client
}

TestServer represents a test server with all plugins loaded

func NewTestServer

func NewTestServer() *TestServer

NewTestServer creates a new test server

func (*TestServer) Close

func (ts *TestServer) Close()

func (*TestServer) Get

func (ts *TestServer) Get(path string) (*http.Response, error)

Helper methods for TestServer

func (*TestServer) Post

func (ts *TestServer) Post(path string, body interface{}) (*http.Response, error)

Jump to

Keyboard shortcuts

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