Documentation
ΒΆ
Index ΒΆ
- func IsHTTPError(err error, statusCode int) bool
- func TestAuthenticationScenarios(t *testing.T)
- func TestErrorHandlingPatterns(t *testing.T)
- func TestRESTfulScenarios(t *testing.T)
- func TestUsageExamples(t *testing.T)
- type APIClient
- func (client *APIClient) AddHeader(key, value string)
- func (client *APIClient) Connect(endpoint string, responseStruct any) error
- func (client *APIClient) Delete(endpoint string, responseStruct any) error
- func (client *APIClient) DeleteWithContext(ctx context.Context, endpoint string, responseStruct any) error
- func (client *APIClient) Get(endpoint string, responseStruct any) error
- func (client *APIClient) GetHeaders() map[string]string
- func (client *APIClient) GetWithContext(ctx context.Context, endpoint string, responseStruct any) error
- func (client *APIClient) Head(endpoint string, responseStruct any) error
- func (client *APIClient) Options(endpoint string, responseStruct any) error
- func (client *APIClient) Patch(endpoint string, requestBody, responseStruct any) error
- func (client *APIClient) PatchWithContext(ctx context.Context, endpoint string, requestBody, responseStruct any) error
- func (client *APIClient) Post(endpoint string, requestBody, responseStruct any) error
- func (client *APIClient) PostWithContext(ctx context.Context, endpoint string, requestBody, responseStruct any) error
- func (client *APIClient) Put(endpoint string, requestBody, responseStruct any) error
- func (client *APIClient) PutWithContext(ctx context.Context, endpoint string, requestBody, responseStruct any) error
- func (client *APIClient) RemoveHeader(key string)
- func (client *APIClient) SetDebugMode(debug bool)
- func (client *APIClient) SetHTTPClient(httpClient *http.Client)
- func (client *APIClient) SetRawMode(raw bool)
- func (client *APIClient) SetTimeout(timeout time.Duration)
- func (client *APIClient) Trace(endpoint string, responseStruct any) error
- func (client *APIClient) UploadFile(endpoint, fieldName, filePath string, additionalFields map[string]string, ...) error
- func (client *APIClient) UploadFileWithContext(ctx context.Context, endpoint, fieldName, filePath string, ...) error
- func (client *APIClient) UploadFiles(endpoint string, files map[string]string, additionalFields map[string]string, ...) error
- func (client *APIClient) UploadFilesWithContext(ctx context.Context, endpoint string, files map[string]string, ...) error
- func (client *APIClient) UploadReader(endpoint, fieldName, fileName string, reader io.Reader, ...) error
- func (client *APIClient) UploadReaderWithContext(ctx context.Context, endpoint, fieldName, fileName string, reader io.Reader, ...) error
- type HTTPError
- type MockServer
- func (m *MockServer) Close()
- func (m *MockServer) Reset()
- func (m *MockServer) SetDelay(delay time.Duration) *MockServer
- func (m *MockServer) SetHandler(handler http.HandlerFunc) *MockServer
- func (m *MockServer) SetHeader(key, value string) *MockServer
- func (m *MockServer) SetResponse(status int, body interface{}) *MockServer
- func (m *MockServer) URL() string
- type TestHelper
- func (h *TestHelper) AssertEqual(expected, actual interface{}, message string)
- func (h *TestHelper) AssertError(err error, message string)
- func (h *TestHelper) AssertFalse(condition bool, message string)
- func (h *TestHelper) AssertNoError(err error, message string)
- func (h *TestHelper) AssertNotEqual(expected, actual interface{}, message string)
- func (h *TestHelper) AssertTrue(condition bool, message string)
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func IsHTTPError ΒΆ added in v1.16.31
func TestAuthenticationScenarios ΒΆ added in v1.16.31
TestAuthenticationScenarios tests various authentication patterns
func TestErrorHandlingPatterns ΒΆ added in v1.16.31
TestErrorHandlingPatterns tests common error handling patterns
func TestRESTfulScenarios ΒΆ added in v1.16.31
TestRESTfulScenarios tests common RESTful API scenarios
func TestUsageExamples ΒΆ added in v1.16.31
TestUsageExamples demonstrates how to use the test helpers
Types ΒΆ
type APIClient ΒΆ
type APIClient struct {
BaseURL string
Headers map[string]string
DebugMode bool
RawMode bool
Client *http.Client
RequestTimeout time.Duration
}
func NewAPIClient ΒΆ
func (*APIClient) DeleteWithContext ΒΆ added in v1.16.31
func (*APIClient) GetHeaders ΒΆ added in v1.16.31
func (*APIClient) GetWithContext ΒΆ added in v1.16.31
func (*APIClient) PatchWithContext ΒΆ added in v1.16.31
func (*APIClient) PostWithContext ΒΆ added in v1.16.31
func (*APIClient) PutWithContext ΒΆ added in v1.16.31
func (*APIClient) RemoveHeader ΒΆ
func (*APIClient) SetDebugMode ΒΆ added in v1.11.91
func (*APIClient) SetHTTPClient ΒΆ added in v1.16.31
func (*APIClient) SetRawMode ΒΆ added in v1.15.14
func (*APIClient) SetTimeout ΒΆ added in v1.16.31
func (*APIClient) UploadFile ΒΆ
func (*APIClient) UploadFileWithContext ΒΆ added in v1.16.31
func (*APIClient) UploadFiles ΒΆ added in v1.16.31
func (*APIClient) UploadFilesWithContext ΒΆ added in v1.16.31
func (*APIClient) UploadReader ΒΆ added in v1.16.31
type HTTPError ΒΆ added in v1.16.31
func GetHTTPError ΒΆ added in v1.16.31
type MockServer ΒΆ added in v1.16.31
type MockServer struct {
Server *httptest.Server
RequestCount int
LastRequest *http.Request
ResponseStatus int
ResponseBody interface{}
ResponseDelay time.Duration
ResponseHeaders map[string]string
Handler http.HandlerFunc
}
MockServer represents a configurable mock HTTP server
func NewMockServer ΒΆ added in v1.16.31
func NewMockServer() *MockServer
NewMockServer creates a new mock server with default settings
func (*MockServer) Close ΒΆ added in v1.16.31
func (m *MockServer) Close()
Close closes the mock server
func (*MockServer) Reset ΒΆ added in v1.16.31
func (m *MockServer) Reset()
Reset resets the mock server state
func (*MockServer) SetDelay ΒΆ added in v1.16.31
func (m *MockServer) SetDelay(delay time.Duration) *MockServer
SetDelay configures a response delay
func (*MockServer) SetHandler ΒΆ added in v1.16.31
func (m *MockServer) SetHandler(handler http.HandlerFunc) *MockServer
SetHandler sets a custom handler function
func (*MockServer) SetHeader ΒΆ added in v1.16.31
func (m *MockServer) SetHeader(key, value string) *MockServer
SetHeader adds a response header
func (*MockServer) SetResponse ΒΆ added in v1.16.31
func (m *MockServer) SetResponse(status int, body interface{}) *MockServer
SetResponse configures the mock server response
func (*MockServer) URL ΒΆ added in v1.16.31
func (m *MockServer) URL() string
URL returns the server URL
type TestHelper ΒΆ added in v1.16.31
type TestHelper struct {
// contains filtered or unexported fields
}
TestHelper provides utility functions for testing
func NewTestHelper ΒΆ added in v1.16.31
func NewTestHelper(t *testing.T) *TestHelper
NewTestHelper creates a new test helper
func (*TestHelper) AssertEqual ΒΆ added in v1.16.31
func (h *TestHelper) AssertEqual(expected, actual interface{}, message string)
AssertEqual checks if two values are equal
func (*TestHelper) AssertError ΒΆ added in v1.16.31
func (h *TestHelper) AssertError(err error, message string)
AssertError fails the test if err is nil
func (*TestHelper) AssertFalse ΒΆ added in v1.16.31
func (h *TestHelper) AssertFalse(condition bool, message string)
AssertFalse checks if condition is false
func (*TestHelper) AssertNoError ΒΆ added in v1.16.31
func (h *TestHelper) AssertNoError(err error, message string)
AssertNoError fails the test if err is not nil
func (*TestHelper) AssertNotEqual ΒΆ added in v1.16.31
func (h *TestHelper) AssertNotEqual(expected, actual interface{}, message string)
AssertNotEqual checks if two values are not equal
func (*TestHelper) AssertTrue ΒΆ added in v1.16.31
func (h *TestHelper) AssertTrue(condition bool, message string)
AssertTrue checks if condition is true