Documentation
¶
Index ¶
- func Exec(t *testing.T, env *TestEnv, args ...string) (stdout, stderr string, err error)
- func FindContextEntry(t *testing.T, path, name string) *config.ContextEntry
- func WriteConfigFile(t *testing.T, dir string, content map[string]any) string
- func WriteContextConfigFile(t *testing.T, dir, currentContext string, ...) string
- func WriteYAMLConfigFile(t *testing.T, dir string, content map[string]any) string
- type FakeBackupService
- func (f *FakeBackupService) CreateBackup(ctx context.Context, req *backupv1.CreateBackupRequest) (*backupv1.CreateBackupResponse, error)
- func (f *FakeBackupService) CreateBackupSchedule(ctx context.Context, req *backupv1.CreateBackupScheduleRequest) (*backupv1.CreateBackupScheduleResponse, error)
- func (f *FakeBackupService) DeleteBackup(ctx context.Context, req *backupv1.DeleteBackupRequest) (*backupv1.DeleteBackupResponse, error)
- func (f *FakeBackupService) DeleteBackupSchedule(ctx context.Context, req *backupv1.DeleteBackupScheduleRequest) (*backupv1.DeleteBackupScheduleResponse, error)
- func (f *FakeBackupService) GetBackup(ctx context.Context, req *backupv1.GetBackupRequest) (*backupv1.GetBackupResponse, error)
- func (f *FakeBackupService) GetBackupSchedule(ctx context.Context, req *backupv1.GetBackupScheduleRequest) (*backupv1.GetBackupScheduleResponse, error)
- func (f *FakeBackupService) ListBackupRestores(ctx context.Context, req *backupv1.ListBackupRestoresRequest) (*backupv1.ListBackupRestoresResponse, error)
- func (f *FakeBackupService) ListBackupSchedules(ctx context.Context, req *backupv1.ListBackupSchedulesRequest) (*backupv1.ListBackupSchedulesResponse, error)
- func (f *FakeBackupService) ListBackups(ctx context.Context, req *backupv1.ListBackupsRequest) (*backupv1.ListBackupsResponse, error)
- func (f *FakeBackupService) RestoreBackup(ctx context.Context, req *backupv1.RestoreBackupRequest) (*backupv1.RestoreBackupResponse, error)
- func (f *FakeBackupService) UpdateBackupSchedule(ctx context.Context, req *backupv1.UpdateBackupScheduleRequest) (*backupv1.UpdateBackupScheduleResponse, error)
- type FakeBookingService
- type FakeClusterService
- func (f *FakeClusterService) CreateCluster(ctx context.Context, req *clusterv1.CreateClusterRequest) (*clusterv1.CreateClusterResponse, error)
- func (f *FakeClusterService) DeleteCluster(ctx context.Context, req *clusterv1.DeleteClusterRequest) (*clusterv1.DeleteClusterResponse, error)
- func (f *FakeClusterService) GetCluster(ctx context.Context, req *clusterv1.GetClusterRequest) (*clusterv1.GetClusterResponse, error)
- func (f *FakeClusterService) ListClusters(ctx context.Context, req *clusterv1.ListClustersRequest) (*clusterv1.ListClustersResponse, error)
- func (f *FakeClusterService) ListQdrantReleases(ctx context.Context, req *clusterv1.ListQdrantReleasesRequest) (*clusterv1.ListQdrantReleasesResponse, error)
- func (f *FakeClusterService) RestartCluster(ctx context.Context, req *clusterv1.RestartClusterRequest) (*clusterv1.RestartClusterResponse, error)
- func (f *FakeClusterService) SuggestClusterName(ctx context.Context, req *clusterv1.SuggestClusterNameRequest) (*clusterv1.SuggestClusterNameResponse, error)
- func (f *FakeClusterService) SuspendCluster(ctx context.Context, req *clusterv1.SuspendClusterRequest) (*clusterv1.SuspendClusterResponse, error)
- func (f *FakeClusterService) UnsuspendCluster(ctx context.Context, req *clusterv1.UnsuspendClusterRequest) (*clusterv1.UnsuspendClusterResponse, error)
- func (f *FakeClusterService) UpdateCluster(ctx context.Context, req *clusterv1.UpdateClusterRequest) (*clusterv1.UpdateClusterResponse, error)
- type FakeDatabaseApiKeyService
- func (f *FakeDatabaseApiKeyService) CreateDatabaseApiKey(ctx context.Context, req *clusterauthv2.CreateDatabaseApiKeyRequest) (*clusterauthv2.CreateDatabaseApiKeyResponse, error)
- func (f *FakeDatabaseApiKeyService) DeleteDatabaseApiKey(ctx context.Context, req *clusterauthv2.DeleteDatabaseApiKeyRequest) (*clusterauthv2.DeleteDatabaseApiKeyResponse, error)
- func (f *FakeDatabaseApiKeyService) ListDatabaseApiKeys(ctx context.Context, req *clusterauthv2.ListDatabaseApiKeysRequest) (*clusterauthv2.ListDatabaseApiKeysResponse, error)
- type FakePlatformService
- func (f *FakePlatformService) ListCloudProviderRegions(ctx context.Context, req *platformv1.ListCloudProviderRegionsRequest) (*platformv1.ListCloudProviderRegionsResponse, error)
- func (f *FakePlatformService) ListCloudProviders(ctx context.Context, req *platformv1.ListCloudProvidersRequest) (*platformv1.ListCloudProvidersResponse, error)
- type MethodSpy
- func (m *MethodSpy[Req, Resp]) All() []Req
- func (m *MethodSpy[Req, Resp]) Always(fn func(context.Context, Req) (Resp, error)) *MethodSpy[Req, Resp]
- func (m *MethodSpy[Req, Resp]) Count() int
- func (m *MethodSpy[Req, Resp]) Last() (Req, bool)
- func (m *MethodSpy[Req, Resp]) OnCall(i int, fn func(context.Context, Req) (Resp, error)) *MethodSpy[Req, Resp]
- func (m *MethodSpy[Req, Resp]) Reset()
- func (m *MethodSpy[Req, Resp]) Returns(resp Resp, err error) *MethodSpy[Req, Resp]
- type Option
- type RequestCapture
- type TestEnv
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exec ¶
Exec builds and executes the root command with the given args, returning captured stdout, stderr, and any error from cmd.Execute().
func FindContextEntry ¶
func FindContextEntry(t *testing.T, path, name string) *config.ContextEntry
FindContextEntry reads the YAML config file at path and returns a pointer to the ContextEntry whose Name matches name, or nil if not found.
func WriteConfigFile ¶
WriteConfigFile marshals content as JSON and writes it to dir/config.json. Returns the full path for use with --config or QDRANT_CLOUD_CONFIG.
func WriteContextConfigFile ¶
func WriteContextConfigFile(t *testing.T, dir, currentContext string, contexts map[string]map[string]string) string
WriteContextConfigFile writes a context-format YAML config file to dir/config.yaml. Contexts are written as a YAML slice (- name: ...) sorted by name for deterministic output. Returns the full path for use with --config or QDRANT_CLOUD_CONFIG.
Types ¶
type FakeBackupService ¶ added in v0.2.0
type FakeBackupService struct {
backupv1.UnimplementedBackupServiceServer
ListBackupsCalls MethodSpy[*backupv1.ListBackupsRequest, *backupv1.ListBackupsResponse]
GetBackupCalls MethodSpy[*backupv1.GetBackupRequest, *backupv1.GetBackupResponse]
CreateBackupCalls MethodSpy[*backupv1.CreateBackupRequest, *backupv1.CreateBackupResponse]
DeleteBackupCalls MethodSpy[*backupv1.DeleteBackupRequest, *backupv1.DeleteBackupResponse]
ListBackupRestoresCalls MethodSpy[*backupv1.ListBackupRestoresRequest, *backupv1.ListBackupRestoresResponse]
RestoreBackupCalls MethodSpy[*backupv1.RestoreBackupRequest, *backupv1.RestoreBackupResponse]
ListBackupSchedulesCalls MethodSpy[*backupv1.ListBackupSchedulesRequest, *backupv1.ListBackupSchedulesResponse]
GetBackupScheduleCalls MethodSpy[*backupv1.GetBackupScheduleRequest, *backupv1.GetBackupScheduleResponse]
CreateBackupScheduleCalls MethodSpy[*backupv1.CreateBackupScheduleRequest, *backupv1.CreateBackupScheduleResponse]
UpdateBackupScheduleCalls MethodSpy[*backupv1.UpdateBackupScheduleRequest, *backupv1.UpdateBackupScheduleResponse]
DeleteBackupScheduleCalls MethodSpy[*backupv1.DeleteBackupScheduleRequest, *backupv1.DeleteBackupScheduleResponse]
}
FakeBackupService is a test fake that implements BackupServiceServer. Use the *Calls fields to configure responses and inspect captured requests.
func (*FakeBackupService) CreateBackup ¶ added in v0.2.0
func (f *FakeBackupService) CreateBackup(ctx context.Context, req *backupv1.CreateBackupRequest) (*backupv1.CreateBackupResponse, error)
CreateBackup records the call and dispatches via CreateBackupCalls.
func (*FakeBackupService) CreateBackupSchedule ¶ added in v0.2.0
func (f *FakeBackupService) CreateBackupSchedule(ctx context.Context, req *backupv1.CreateBackupScheduleRequest) (*backupv1.CreateBackupScheduleResponse, error)
CreateBackupSchedule records the call and dispatches via CreateBackupScheduleCalls.
func (*FakeBackupService) DeleteBackup ¶ added in v0.2.0
func (f *FakeBackupService) DeleteBackup(ctx context.Context, req *backupv1.DeleteBackupRequest) (*backupv1.DeleteBackupResponse, error)
DeleteBackup records the call and dispatches via DeleteBackupCalls.
func (*FakeBackupService) DeleteBackupSchedule ¶ added in v0.2.0
func (f *FakeBackupService) DeleteBackupSchedule(ctx context.Context, req *backupv1.DeleteBackupScheduleRequest) (*backupv1.DeleteBackupScheduleResponse, error)
DeleteBackupSchedule records the call and dispatches via DeleteBackupScheduleCalls.
func (*FakeBackupService) GetBackup ¶ added in v0.2.0
func (f *FakeBackupService) GetBackup(ctx context.Context, req *backupv1.GetBackupRequest) (*backupv1.GetBackupResponse, error)
GetBackup records the call and dispatches via GetBackupCalls.
func (*FakeBackupService) GetBackupSchedule ¶ added in v0.2.0
func (f *FakeBackupService) GetBackupSchedule(ctx context.Context, req *backupv1.GetBackupScheduleRequest) (*backupv1.GetBackupScheduleResponse, error)
GetBackupSchedule records the call and dispatches via GetBackupScheduleCalls.
func (*FakeBackupService) ListBackupRestores ¶ added in v0.2.0
func (f *FakeBackupService) ListBackupRestores(ctx context.Context, req *backupv1.ListBackupRestoresRequest) (*backupv1.ListBackupRestoresResponse, error)
ListBackupRestores records the call and dispatches via ListBackupRestoresCalls.
func (*FakeBackupService) ListBackupSchedules ¶ added in v0.2.0
func (f *FakeBackupService) ListBackupSchedules(ctx context.Context, req *backupv1.ListBackupSchedulesRequest) (*backupv1.ListBackupSchedulesResponse, error)
ListBackupSchedules records the call and dispatches via ListBackupSchedulesCalls.
func (*FakeBackupService) ListBackups ¶ added in v0.2.0
func (f *FakeBackupService) ListBackups(ctx context.Context, req *backupv1.ListBackupsRequest) (*backupv1.ListBackupsResponse, error)
ListBackups records the call and dispatches via ListBackupsCalls.
func (*FakeBackupService) RestoreBackup ¶ added in v0.2.0
func (f *FakeBackupService) RestoreBackup(ctx context.Context, req *backupv1.RestoreBackupRequest) (*backupv1.RestoreBackupResponse, error)
RestoreBackup records the call and dispatches via RestoreBackupCalls.
func (*FakeBackupService) UpdateBackupSchedule ¶ added in v0.2.0
func (f *FakeBackupService) UpdateBackupSchedule(ctx context.Context, req *backupv1.UpdateBackupScheduleRequest) (*backupv1.UpdateBackupScheduleResponse, error)
UpdateBackupSchedule records the call and dispatches via UpdateBackupScheduleCalls.
type FakeBookingService ¶
type FakeBookingService struct {
bookingv1.UnimplementedBookingServiceServer
ListPackagesCalls MethodSpy[*bookingv1.ListPackagesRequest, *bookingv1.ListPackagesResponse]
}
FakeBookingService is a test fake that implements BookingServiceServer. Use the *Calls fields to configure responses and inspect captured requests.
func (*FakeBookingService) ListPackages ¶
func (f *FakeBookingService) ListPackages(ctx context.Context, req *bookingv1.ListPackagesRequest) (*bookingv1.ListPackagesResponse, error)
ListPackages records the call and dispatches via ListPackagesCalls.
type FakeClusterService ¶
type FakeClusterService struct {
clusterv1.UnimplementedClusterServiceServer
ListClustersCalls MethodSpy[*clusterv1.ListClustersRequest, *clusterv1.ListClustersResponse]
GetClusterCalls MethodSpy[*clusterv1.GetClusterRequest, *clusterv1.GetClusterResponse]
CreateClusterCalls MethodSpy[*clusterv1.CreateClusterRequest, *clusterv1.CreateClusterResponse]
UpdateClusterCalls MethodSpy[*clusterv1.UpdateClusterRequest, *clusterv1.UpdateClusterResponse]
DeleteClusterCalls MethodSpy[*clusterv1.DeleteClusterRequest, *clusterv1.DeleteClusterResponse]
RestartClusterCalls MethodSpy[*clusterv1.RestartClusterRequest, *clusterv1.RestartClusterResponse]
SuspendClusterCalls MethodSpy[*clusterv1.SuspendClusterRequest, *clusterv1.SuspendClusterResponse]
UnsuspendClusterCalls MethodSpy[*clusterv1.UnsuspendClusterRequest, *clusterv1.UnsuspendClusterResponse]
SuggestClusterNameCalls MethodSpy[*clusterv1.SuggestClusterNameRequest, *clusterv1.SuggestClusterNameResponse]
ListQdrantReleasesCalls MethodSpy[*clusterv1.ListQdrantReleasesRequest, *clusterv1.ListQdrantReleasesResponse]
}
FakeClusterService is a test fake that implements ClusterServiceServer. Use the *Calls fields to configure responses and inspect captured requests.
func (*FakeClusterService) CreateCluster ¶
func (f *FakeClusterService) CreateCluster(ctx context.Context, req *clusterv1.CreateClusterRequest) (*clusterv1.CreateClusterResponse, error)
CreateCluster records the call and dispatches via CreateClusterCalls.
func (*FakeClusterService) DeleteCluster ¶
func (f *FakeClusterService) DeleteCluster(ctx context.Context, req *clusterv1.DeleteClusterRequest) (*clusterv1.DeleteClusterResponse, error)
DeleteCluster records the call and dispatches via DeleteClusterCalls.
func (*FakeClusterService) GetCluster ¶
func (f *FakeClusterService) GetCluster(ctx context.Context, req *clusterv1.GetClusterRequest) (*clusterv1.GetClusterResponse, error)
GetCluster records the call and dispatches via GetClusterCalls.
func (*FakeClusterService) ListClusters ¶
func (f *FakeClusterService) ListClusters(ctx context.Context, req *clusterv1.ListClustersRequest) (*clusterv1.ListClustersResponse, error)
ListClusters records the call and dispatches via ListClustersCalls.
func (*FakeClusterService) ListQdrantReleases ¶
func (f *FakeClusterService) ListQdrantReleases(ctx context.Context, req *clusterv1.ListQdrantReleasesRequest) (*clusterv1.ListQdrantReleasesResponse, error)
ListQdrantReleases records the call and dispatches via ListQdrantReleasesCalls.
func (*FakeClusterService) RestartCluster ¶
func (f *FakeClusterService) RestartCluster(ctx context.Context, req *clusterv1.RestartClusterRequest) (*clusterv1.RestartClusterResponse, error)
RestartCluster records the call and dispatches via RestartClusterCalls.
func (*FakeClusterService) SuggestClusterName ¶
func (f *FakeClusterService) SuggestClusterName(ctx context.Context, req *clusterv1.SuggestClusterNameRequest) (*clusterv1.SuggestClusterNameResponse, error)
SuggestClusterName records the call and dispatches via SuggestClusterNameCalls.
func (*FakeClusterService) SuspendCluster ¶
func (f *FakeClusterService) SuspendCluster(ctx context.Context, req *clusterv1.SuspendClusterRequest) (*clusterv1.SuspendClusterResponse, error)
SuspendCluster records the call and dispatches via SuspendClusterCalls.
func (*FakeClusterService) UnsuspendCluster ¶
func (f *FakeClusterService) UnsuspendCluster(ctx context.Context, req *clusterv1.UnsuspendClusterRequest) (*clusterv1.UnsuspendClusterResponse, error)
UnsuspendCluster records the call and dispatches via UnsuspendClusterCalls.
func (*FakeClusterService) UpdateCluster ¶
func (f *FakeClusterService) UpdateCluster(ctx context.Context, req *clusterv1.UpdateClusterRequest) (*clusterv1.UpdateClusterResponse, error)
UpdateCluster records the call and dispatches via UpdateClusterCalls.
type FakeDatabaseApiKeyService ¶
type FakeDatabaseApiKeyService struct {
clusterauthv2.UnimplementedDatabaseApiKeyServiceServer
ListDatabaseApiKeysCalls MethodSpy[*clusterauthv2.ListDatabaseApiKeysRequest, *clusterauthv2.ListDatabaseApiKeysResponse]
CreateDatabaseApiKeyCalls MethodSpy[*clusterauthv2.CreateDatabaseApiKeyRequest, *clusterauthv2.CreateDatabaseApiKeyResponse]
DeleteDatabaseApiKeyCalls MethodSpy[*clusterauthv2.DeleteDatabaseApiKeyRequest, *clusterauthv2.DeleteDatabaseApiKeyResponse]
}
FakeDatabaseApiKeyService is a test fake that implements DatabaseApiKeyServiceServer. Use the *Calls fields to configure responses and inspect captured requests.
func (*FakeDatabaseApiKeyService) CreateDatabaseApiKey ¶
func (f *FakeDatabaseApiKeyService) CreateDatabaseApiKey(ctx context.Context, req *clusterauthv2.CreateDatabaseApiKeyRequest) (*clusterauthv2.CreateDatabaseApiKeyResponse, error)
CreateDatabaseApiKey records the call and dispatches via CreateDatabaseApiKeyCalls.
func (*FakeDatabaseApiKeyService) DeleteDatabaseApiKey ¶
func (f *FakeDatabaseApiKeyService) DeleteDatabaseApiKey(ctx context.Context, req *clusterauthv2.DeleteDatabaseApiKeyRequest) (*clusterauthv2.DeleteDatabaseApiKeyResponse, error)
DeleteDatabaseApiKey records the call and dispatches via DeleteDatabaseApiKeyCalls.
func (*FakeDatabaseApiKeyService) ListDatabaseApiKeys ¶
func (f *FakeDatabaseApiKeyService) ListDatabaseApiKeys(ctx context.Context, req *clusterauthv2.ListDatabaseApiKeysRequest) (*clusterauthv2.ListDatabaseApiKeysResponse, error)
ListDatabaseApiKeys records the call and dispatches via ListDatabaseApiKeysCalls.
type FakePlatformService ¶
type FakePlatformService struct {
platformv1.UnimplementedPlatformServiceServer
ListCloudProvidersCalls MethodSpy[*platformv1.ListCloudProvidersRequest, *platformv1.ListCloudProvidersResponse]
ListCloudProviderRegionsCalls MethodSpy[*platformv1.ListCloudProviderRegionsRequest, *platformv1.ListCloudProviderRegionsResponse]
}
FakePlatformService is a test fake that implements PlatformServiceServer. Use the *Calls fields to configure responses and inspect captured requests.
func (*FakePlatformService) ListCloudProviderRegions ¶
func (f *FakePlatformService) ListCloudProviderRegions(ctx context.Context, req *platformv1.ListCloudProviderRegionsRequest) (*platformv1.ListCloudProviderRegionsResponse, error)
ListCloudProviderRegions records the call and dispatches via ListCloudProviderRegionsCalls.
func (*FakePlatformService) ListCloudProviders ¶
func (f *FakePlatformService) ListCloudProviders(ctx context.Context, req *platformv1.ListCloudProvidersRequest) (*platformv1.ListCloudProvidersResponse, error)
ListCloudProviders records the call and dispatches via ListCloudProvidersCalls.
type MethodSpy ¶ added in v0.3.0
type MethodSpy[Req, Resp any] struct { // contains filtered or unexported fields }
MethodSpy records calls to a single RPC method and optionally dispatches to per-call or fallback handlers. Use the *Calls fields on fake services instead of managing call counters and captured requests manually.
Priority when handling a call: *Func field > OnCall handler > Always handler > Unimplemented default.
func (*MethodSpy[Req, Resp]) All ¶ added in v0.3.0
func (m *MethodSpy[Req, Resp]) All() []Req
All returns a copy of all captured requests in call order.
func (*MethodSpy[Req, Resp]) Always ¶ added in v0.3.0
func (m *MethodSpy[Req, Resp]) Always(fn func(context.Context, Req) (Resp, error)) *MethodSpy[Req, Resp]
Always sets a fallback handler invoked for every call that has no matching OnCall entry. If neither OnCall nor Always is set the method falls back to the gRPC Unimplemented default.
func (*MethodSpy[Req, Resp]) Count ¶ added in v0.3.0
Count returns how many times the method has been called.
func (*MethodSpy[Req, Resp]) Last ¶ added in v0.3.0
Last returns the most recent request and true, or the zero value and false if never called.
func (*MethodSpy[Req, Resp]) OnCall ¶ added in v0.3.0
func (m *MethodSpy[Req, Resp]) OnCall(i int, fn func(context.Context, Req) (Resp, error)) *MethodSpy[Req, Resp]
OnCall registers a handler for the i-th call (0-indexed). Chainable.
type Option ¶
type Option func(*envConfig)
Option configures a TestEnv.
func WithAPIKey ¶
WithAPIKey sets the API key used by the test client's auth interceptor.
func WithAccountID ¶
WithAccountID sets the default account ID pre-configured on the test state.
func WithVersion ¶
WithVersion sets the CLI version used in the user-agent header.
type RequestCapture ¶
type RequestCapture struct {
// contains filtered or unexported fields
}
RequestCapture is a server-side unary interceptor that records incoming metadata.
func (*RequestCapture) Last ¶
func (rc *RequestCapture) Last() metadata.MD
Last returns the metadata from the most recent request.
type TestEnv ¶
type TestEnv struct {
State *state.State
Server *FakeClusterService
BookingServer *FakeBookingService
PlatformServer *FakePlatformService
DatabaseApiKeyServer *FakeDatabaseApiKeyService
BackupServer *FakeBackupService
Capture *RequestCapture
Cleanup func()
}
TestEnv bundles everything a test needs.
func NewBareTestEnv ¶
NewBareTestEnv creates a test environment with a bufconn-backed gRPC server but with no config values pre-populated in viper. Use this when the test itself controls how config is loaded — for example, to verify that account_id is read from a config file, an environment variable, or a CLI flag.
func NewTestEnv ¶
NewTestEnv creates a test environment with a bufconn-backed gRPC server and a pre-populated config. account_id and api_key are set via the highest viper priority (Set), so they reliably override any machine environment variables. Use this for testing command behaviour where a valid account ID is needed but its specific source doesn't matter. Defaults: account_id="test-account-id". Override with WithAccountID / WithAPIKey.