testing

package
v0.9.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testing provides test utilities for the Nexlayer API client

Index

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

Jump to

Keyboard shortcuts

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