apitest

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAccount

func NewAccount(opts ...func(*domain.Account)) domain.Account

NewAccount creates a test account with sensible defaults. Use functional options to override specific fields.

func NewMockAPIServices

func NewMockAPIServices(
	organizations *MockOrganizations,
	accounts *MockAccounts,
	workspaces *MockWorkspaces,
	datadogAccounts *MockDatadogAccounts,
) api.APIServices

NewMockAPIServices creates an APIServices with mock implementations. Pass nil for any service you don't need to mock.

func NewOrganization

func NewOrganization(opts ...func(*domain.Organization)) domain.Organization

NewOrganization creates a test organization with sensible defaults. Use functional options to override specific fields.

func NewWorkspace

func NewWorkspace(opts ...func(*domain.Workspace)) domain.Workspace

NewWorkspace creates a test workspace with sensible defaults. Use functional options to override specific fields.

Types

type MockAPIServiceServices added in v1.15.0

type MockAPIServiceServices struct {
	EnableServiceFunc  func(ctx context.Context, serviceID domain.ServiceID) error
	DisableServiceFunc func(ctx context.Context, serviceID domain.ServiceID) error
}

MockAPIServiceServices is a mock implementation of api.Services.

func NewMockAPIServiceServices added in v1.15.0

func NewMockAPIServiceServices() *MockAPIServiceServices

NewMockAPIServiceServices creates a MockAPIServiceServices with sensible defaults.

func (*MockAPIServiceServices) DisableService added in v1.15.0

func (m *MockAPIServiceServices) DisableService(ctx context.Context, serviceID domain.ServiceID) error

func (*MockAPIServiceServices) EnableService added in v1.15.0

func (m *MockAPIServiceServices) EnableService(ctx context.Context, serviceID domain.ServiceID) error

type MockAccounts

type MockAccounts struct {
	ListFunc   func(ctx context.Context, organizationID domain.OrganizationID) ([]domain.Account, error)
	GetFunc    func(ctx context.Context, accountID domain.AccountID) (*domain.Account, error)
	CreateFunc func(ctx context.Context, input api.CreateAccountInput) (*domain.Account, error)
}

MockAccounts implements api.Accounts for testing.

func NewMockAccounts

func NewMockAccounts() *MockAccounts

NewMockAccounts creates a MockAccounts with sensible defaults.

func (*MockAccounts) Create

func (*MockAccounts) Get

func (m *MockAccounts) Get(ctx context.Context, accountID domain.AccountID) (*domain.Account, error)

func (*MockAccounts) List

func (m *MockAccounts) List(ctx context.Context, organizationID domain.OrganizationID) ([]domain.Account, error)

type MockClient

type MockClient struct {
	SetAccountIDFunc                        func(accountID domain.AccountID)
	RawQueryFunc                            func(ctx context.Context, query string, variables map[string]interface{}) (map[string]interface{}, error)
	ListOrganizationsFunc                   func(ctx context.Context) (*gen.ListOrganizationsResponse, error)
	CreateOrganizationAndBootstrapFunc      func(ctx context.Context, input gen.CreateOrganizationInput) (*gen.CreateOrganizationAndBootstrapResponse, error)
	ListAccountsFunc                        func(ctx context.Context, organizationID string) (*gen.ListAccountsResponse, error)
	CreateAccountFunc                       func(ctx context.Context, input gen.CreateAccountInput) (*gen.CreateAccountResponse, error)
	GetAccountFunc                          func(ctx context.Context, accountID string) (*gen.GetAccountResponse, error)
	ValidateDatadogApiKeyFunc               func(ctx context.Context, input gen.ValidateDatadogApiKeyInput) (*gen.ValidateDatadogApiKeyResponse, error)
	CreateDatadogAccountWithCredentialsFunc func(ctx context.Context, input gen.CreateDatadogAccountWithCredentialsInput) (*gen.CreateDatadogAccountWithCredentialsResponse, error)
	GetDatadogAccountStatusFunc             func(ctx context.Context, id string) (*gen.GetDatadogAccountStatusResponse, error)
	ListWorkspacesFunc                      func(ctx context.Context, accountID string) (*gen.ListWorkspacesResponse, error)
	CreateConversationFunc                  func(ctx context.Context, input gen.CreateConversationInput) (*gen.CreateConversationResponse, error)
	UpdateConversationFunc                  func(ctx context.Context, id string, input gen.UpdateConversationInput) (*gen.UpdateConversationResponse, error)
	DeleteConversationFunc                  func(ctx context.Context, id string) (*gen.DeleteConversationResponse, error)
	CreateMessageFunc                       func(ctx context.Context, input gen.CreateMessageInput) (*gen.CreateMessageResponse, error)
	EnableServiceFunc                       func(ctx context.Context, serviceID string) (*gen.EnableServiceResponse, error)
	DisableServiceFunc                      func(ctx context.Context, serviceID string) (*gen.DisableServiceResponse, error)
	ApproveLogEventPolicyFunc               func(ctx context.Context, policyID string) (*gen.ApproveLogEventPolicyResponse, error)
	DismissLogEventPolicyFunc               func(ctx context.Context, policyID string) (*gen.DismissLogEventPolicyResponse, error)
}

MockClient implements api.Client for testing.

func NewMockClient

func NewMockClient() *MockClient

NewMockClient creates a MockClient with sensible defaults.

func (*MockClient) ApproveLogEventPolicy added in v1.21.0

func (m *MockClient) ApproveLogEventPolicy(ctx context.Context, policyID string) (*gen.ApproveLogEventPolicyResponse, error)

func (*MockClient) CreateAccount

func (*MockClient) CreateConversation

func (*MockClient) CreateMessage

func (*MockClient) CreateOrganizationAndBootstrap

func (m *MockClient) CreateOrganizationAndBootstrap(ctx context.Context, input gen.CreateOrganizationInput) (*gen.CreateOrganizationAndBootstrapResponse, error)

func (*MockClient) DeleteConversation

func (m *MockClient) DeleteConversation(ctx context.Context, id string) (*gen.DeleteConversationResponse, error)

func (*MockClient) DisableService added in v1.15.0

func (m *MockClient) DisableService(ctx context.Context, serviceID string) (*gen.DisableServiceResponse, error)

func (*MockClient) DismissLogEventPolicy added in v1.21.0

func (m *MockClient) DismissLogEventPolicy(ctx context.Context, policyID string) (*gen.DismissLogEventPolicyResponse, error)

func (*MockClient) EnableService added in v1.15.0

func (m *MockClient) EnableService(ctx context.Context, serviceID string) (*gen.EnableServiceResponse, error)

func (*MockClient) GetAccount

func (m *MockClient) GetAccount(ctx context.Context, accountID string) (*gen.GetAccountResponse, error)

func (*MockClient) GetDatadogAccountStatus

func (m *MockClient) GetDatadogAccountStatus(ctx context.Context, id string) (*gen.GetDatadogAccountStatusResponse, error)

func (*MockClient) ListAccounts

func (m *MockClient) ListAccounts(ctx context.Context, organizationID string) (*gen.ListAccountsResponse, error)

func (*MockClient) ListOrganizations

func (m *MockClient) ListOrganizations(ctx context.Context) (*gen.ListOrganizationsResponse, error)

func (*MockClient) ListWorkspaces

func (m *MockClient) ListWorkspaces(ctx context.Context, accountID string) (*gen.ListWorkspacesResponse, error)

func (*MockClient) RawQuery

func (m *MockClient) RawQuery(ctx context.Context, query string, variables map[string]interface{}) (map[string]interface{}, error)

func (*MockClient) SetAccountID

func (m *MockClient) SetAccountID(accountID domain.AccountID)

func (*MockClient) UpdateConversation

func (*MockClient) ValidateDatadogApiKey

type MockConversations

type MockConversations struct {
	CreateFunc func(ctx context.Context, input api.CreateConversationInput) (*domain.Conversation, error)
	UpdateFunc func(ctx context.Context, id domain.ConversationID, input api.UpdateConversationInput) (*domain.Conversation, error)
	DeleteFunc func(ctx context.Context, id domain.ConversationID) error
}

MockConversations implements api.Conversations for testing.

func NewMockConversations

func NewMockConversations() *MockConversations

NewMockConversations creates a MockConversations with sensible defaults.

func (*MockConversations) Create

func (*MockConversations) Delete

func (*MockConversations) Update

type MockDatadogAccounts

type MockDatadogAccounts struct {
	HasAccountFunc     func(ctx context.Context, accountID domain.AccountID) (bool, error)
	GetAccountFunc     func(ctx context.Context, accountID domain.AccountID) (*api.DatadogAccount, error)
	ValidateAPIKeyFunc func(ctx context.Context, input api.ValidateAPIKeyInput) (bool, string, error)
	CreateAccountFunc  func(ctx context.Context, input api.CreateDatadogAccountInput) (*api.DatadogAccount, error)
	GetStatusFunc      func(ctx context.Context, datadogAccountID domain.DatadogAccountID) (*api.DatadogAccountStatus, error)
}

MockDatadogAccounts implements api.DatadogAccounts for testing.

func NewMockDatadogAccounts

func NewMockDatadogAccounts() *MockDatadogAccounts

NewMockDatadogAccounts creates a MockDatadogAccounts with sensible defaults.

func (*MockDatadogAccounts) CreateAccount

func (*MockDatadogAccounts) GetAccount

func (m *MockDatadogAccounts) GetAccount(ctx context.Context, accountID domain.AccountID) (*api.DatadogAccount, error)

func (*MockDatadogAccounts) GetStatus

func (m *MockDatadogAccounts) GetStatus(ctx context.Context, datadogAccountID domain.DatadogAccountID) (*api.DatadogAccountStatus, error)

func (*MockDatadogAccounts) HasAccount

func (m *MockDatadogAccounts) HasAccount(ctx context.Context, accountID domain.AccountID) (bool, error)

func (*MockDatadogAccounts) ValidateAPIKey

func (m *MockDatadogAccounts) ValidateAPIKey(ctx context.Context, input api.ValidateAPIKeyInput) (bool, string, error)

type MockMessages

type MockMessages struct {
	CreateMessageFunc func(ctx context.Context, msg *domain.Message) error
}

MockMessages is a mock implementation of api.Messages.

func NewMockMessages

func NewMockMessages() *MockMessages

NewMockMessages creates a MockMessages with sensible defaults.

func (*MockMessages) CreateMessage

func (m *MockMessages) CreateMessage(ctx context.Context, msg *domain.Message) error

type MockOrganizations

type MockOrganizations struct {
	ListFunc   func(ctx context.Context) ([]domain.Organization, error)
	CreateFunc func(ctx context.Context, input api.CreateOrganizationInput) (*api.OrganizationBootstrapResult, error)
}

MockOrganizations implements api.Organizations for testing.

func NewMockOrganizations

func NewMockOrganizations() *MockOrganizations

NewMockOrganizations creates a MockOrganizations with sensible defaults.

func (*MockOrganizations) Create

func (*MockOrganizations) List

type MockPolicies added in v1.21.0

type MockPolicies struct {
	ApprovePolicyFunc func(ctx context.Context, policyID string) error
	DismissPolicyFunc func(ctx context.Context, policyID string) error
}

MockPolicies is a mock implementation of api.Policies.

func NewMockPolicies added in v1.21.0

func NewMockPolicies() *MockPolicies

NewMockPolicies creates a MockPolicies with sensible defaults.

func (*MockPolicies) ApprovePolicy added in v1.21.0

func (m *MockPolicies) ApprovePolicy(ctx context.Context, policyID string) error

func (*MockPolicies) DismissPolicy added in v1.21.0

func (m *MockPolicies) DismissPolicy(ctx context.Context, policyID string) error

type MockWorkspaces

type MockWorkspaces struct {
	ListFunc func(ctx context.Context, accountID domain.AccountID) ([]domain.Workspace, error)
}

MockWorkspaces implements api.Workspaces for testing.

func NewMockWorkspaces

func NewMockWorkspaces() *MockWorkspaces

NewMockWorkspaces creates a MockWorkspaces with sensible defaults.

func (*MockWorkspaces) List

func (m *MockWorkspaces) List(ctx context.Context, accountID domain.AccountID) ([]domain.Workspace, error)

Jump to

Keyboard shortcuts

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