Documentation
¶
Overview ¶
Package testing provides test utilities for the Nexlayer API client
Index ¶
- type MockAPIClient
- func (m *MockAPIClient) GetDeploymentInfo(ctx context.Context, namespace string, appID string) (*api.APIResponse[api.Deployment], error)
- func (m *MockAPIClient) GetDeployments(ctx context.Context, appID string) (*api.APIResponse[[]api.Deployment], error)
- func (m *MockAPIClient) GetLogs(ctx context.Context, namespace string, appID string, follow bool, tail int) ([]string, error)
- func (m *MockAPIClient) ListDeployments(ctx context.Context) (*api.APIResponse[[]api.Deployment], error)
- func (m *MockAPIClient) SaveCustomDomain(ctx context.Context, appID, domain string) (*api.APIResponse[api.DomainResponse], error)
- func (m *MockAPIClient) SendFeedback(ctx context.Context, text string) error
- func (m *MockAPIClient) StartDeployment(ctx context.Context, appID string, configPath string) (*api.APIResponse[api.DeploymentResponse], error)
- func (m *MockAPIClient) StartDeploymentRaw(ctx context.Context, appID string, yamlData []byte) (*api.APIResponse[api.DeploymentResponse], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockAPIClient ¶
type MockAPIClient struct {
// Mock fields for test control
GetDeploymentsFunc func(ctx context.Context, appID string) (*api.APIResponse[[]api.Deployment], error)
SaveCustomDomainFunc func(ctx context.Context, appID, domain string) (*api.APIResponse[api.DomainResponse], error)
GetLogsFunc func(ctx context.Context, namespace string, appID string, follow bool, tail int) ([]string, error)
GetDeploymentInfoFunc func(ctx context.Context, namespace string, appID string) (*api.APIResponse[api.Deployment], error)
ListDeploymentsFunc func(ctx context.Context) (*api.APIResponse[[]api.Deployment], error)
StartDeploymentFunc func(ctx context.Context, appID string, configPath string) (*api.APIResponse[api.DeploymentResponse], error)
StartDeploymentRawFunc func(ctx context.Context, appID string, yamlData []byte) (*api.APIResponse[api.DeploymentResponse], error)
SendFeedbackFunc func(ctx context.Context, text string) error
}
MockAPIClient implements the api.APIClient interface for testing purposes. It allows for customizing the behavior of each method to simulate different API responses.
func NewTestServer ¶
func NewTestServer(handler http.Handler) (*httptest.Server, *MockAPIClient)
NewTestServer creates a test HTTP server for API testing. It returns both the test server and a mock client that can be used to verify API interactions.
func (*MockAPIClient) GetDeploymentInfo ¶
func (m *MockAPIClient) GetDeploymentInfo(ctx context.Context, namespace string, appID string) (*api.APIResponse[api.Deployment], error)
GetDeploymentInfo mocks retrieving information about a specific deployment.
func (*MockAPIClient) GetDeployments ¶
func (m *MockAPIClient) GetDeployments(ctx context.Context, appID string) (*api.APIResponse[[]api.Deployment], error)
GetDeployments returns a list of deployments for testing.
func (*MockAPIClient) GetLogs ¶
func (m *MockAPIClient) GetLogs(ctx context.Context, namespace string, appID string, follow bool, tail int) ([]string, error)
GetLogs mocks retrieving logs for a deployment.
func (*MockAPIClient) ListDeployments ¶
func (m *MockAPIClient) ListDeployments(ctx context.Context) (*api.APIResponse[[]api.Deployment], error)
ListDeployments mocks listing all deployments.
func (*MockAPIClient) SaveCustomDomain ¶
func (m *MockAPIClient) SaveCustomDomain(ctx context.Context, appID, domain string) (*api.APIResponse[api.DomainResponse], error)
SaveCustomDomain mocks saving a custom domain for an application.
func (*MockAPIClient) SendFeedback ¶
func (m *MockAPIClient) SendFeedback(ctx context.Context, text string) error
SendFeedback mocks sending feedback to the API.
func (*MockAPIClient) StartDeployment ¶
func (m *MockAPIClient) StartDeployment(ctx context.Context, appID string, configPath string) (*api.APIResponse[api.DeploymentResponse], error)
StartDeployment mocks starting a new deployment.
func (*MockAPIClient) StartDeploymentRaw ¶
func (m *MockAPIClient) StartDeploymentRaw(ctx context.Context, appID string, yamlData []byte) (*api.APIResponse[api.DeploymentResponse], error)
StartDeploymentRaw implements api.APIClient