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 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 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 FakeBookingService ¶
type FakeBookingService struct {
bookingv1.UnimplementedBookingServiceServer
ListPackagesFunc func(context.Context, *bookingv1.ListPackagesRequest) (*bookingv1.ListPackagesResponse, error)
}
FakeBookingService is a test fake that implements BookingServiceServer. Set the function fields to control responses per test.
func (*FakeBookingService) ListPackages ¶
func (f *FakeBookingService) ListPackages(ctx context.Context, req *bookingv1.ListPackagesRequest) (*bookingv1.ListPackagesResponse, error)
ListPackages delegates to ListPackagesFunc if set.
type FakeClusterService ¶
type FakeClusterService struct {
clusterv1.UnimplementedClusterServiceServer
ListClustersFunc func(context.Context, *clusterv1.ListClustersRequest) (*clusterv1.ListClustersResponse, error)
GetClusterFunc func(context.Context, *clusterv1.GetClusterRequest) (*clusterv1.GetClusterResponse, error)
CreateClusterFunc func(context.Context, *clusterv1.CreateClusterRequest) (*clusterv1.CreateClusterResponse, error)
UpdateClusterFunc func(context.Context, *clusterv1.UpdateClusterRequest) (*clusterv1.UpdateClusterResponse, error)
DeleteClusterFunc func(context.Context, *clusterv1.DeleteClusterRequest) (*clusterv1.DeleteClusterResponse, error)
RestartClusterFunc func(context.Context, *clusterv1.RestartClusterRequest) (*clusterv1.RestartClusterResponse, error)
SuspendClusterFunc func(context.Context, *clusterv1.SuspendClusterRequest) (*clusterv1.SuspendClusterResponse, error)
UnsuspendClusterFunc func(context.Context, *clusterv1.UnsuspendClusterRequest) (*clusterv1.UnsuspendClusterResponse, error)
SuggestClusterNameFunc func(context.Context, *clusterv1.SuggestClusterNameRequest) (*clusterv1.SuggestClusterNameResponse, error)
ListQdrantReleasesFunc func(context.Context, *clusterv1.ListQdrantReleasesRequest) (*clusterv1.ListQdrantReleasesResponse, error)
}
FakeClusterService is a test fake that implements ClusterServiceServer. Set the function fields to control responses per test.
func (*FakeClusterService) CreateCluster ¶
func (f *FakeClusterService) CreateCluster(ctx context.Context, req *clusterv1.CreateClusterRequest) (*clusterv1.CreateClusterResponse, error)
CreateCluster delegates to CreateClusterFunc if set.
func (*FakeClusterService) DeleteCluster ¶
func (f *FakeClusterService) DeleteCluster(ctx context.Context, req *clusterv1.DeleteClusterRequest) (*clusterv1.DeleteClusterResponse, error)
DeleteCluster delegates to DeleteClusterFunc if set.
func (*FakeClusterService) GetCluster ¶
func (f *FakeClusterService) GetCluster(ctx context.Context, req *clusterv1.GetClusterRequest) (*clusterv1.GetClusterResponse, error)
GetCluster delegates to GetClusterFunc if set.
func (*FakeClusterService) ListClusters ¶
func (f *FakeClusterService) ListClusters(ctx context.Context, req *clusterv1.ListClustersRequest) (*clusterv1.ListClustersResponse, error)
ListClusters delegates to ListClustersFunc if set.
func (*FakeClusterService) ListQdrantReleases ¶
func (f *FakeClusterService) ListQdrantReleases(ctx context.Context, req *clusterv1.ListQdrantReleasesRequest) (*clusterv1.ListQdrantReleasesResponse, error)
ListQdrantReleases delegates to ListQdrantReleasesFunc if set.
func (*FakeClusterService) RestartCluster ¶
func (f *FakeClusterService) RestartCluster(ctx context.Context, req *clusterv1.RestartClusterRequest) (*clusterv1.RestartClusterResponse, error)
RestartCluster delegates to RestartClusterFunc if set.
func (*FakeClusterService) SuggestClusterName ¶
func (f *FakeClusterService) SuggestClusterName(ctx context.Context, req *clusterv1.SuggestClusterNameRequest) (*clusterv1.SuggestClusterNameResponse, error)
SuggestClusterName delegates to SuggestClusterNameFunc if set.
func (*FakeClusterService) SuspendCluster ¶
func (f *FakeClusterService) SuspendCluster(ctx context.Context, req *clusterv1.SuspendClusterRequest) (*clusterv1.SuspendClusterResponse, error)
SuspendCluster delegates to SuspendClusterFunc if set.
func (*FakeClusterService) UnsuspendCluster ¶
func (f *FakeClusterService) UnsuspendCluster(ctx context.Context, req *clusterv1.UnsuspendClusterRequest) (*clusterv1.UnsuspendClusterResponse, error)
UnsuspendCluster delegates to UnsuspendClusterFunc if set.
func (*FakeClusterService) UpdateCluster ¶
func (f *FakeClusterService) UpdateCluster(ctx context.Context, req *clusterv1.UpdateClusterRequest) (*clusterv1.UpdateClusterResponse, error)
UpdateCluster delegates to UpdateClusterFunc if set.
type FakeDatabaseApiKeyService ¶
type FakeDatabaseApiKeyService struct {
clusterauthv2.UnimplementedDatabaseApiKeyServiceServer
ListDatabaseApiKeysFunc func(context.Context, *clusterauthv2.ListDatabaseApiKeysRequest) (*clusterauthv2.ListDatabaseApiKeysResponse, error)
CreateDatabaseApiKeyFunc func(context.Context, *clusterauthv2.CreateDatabaseApiKeyRequest) (*clusterauthv2.CreateDatabaseApiKeyResponse, error)
DeleteDatabaseApiKeyFunc func(context.Context, *clusterauthv2.DeleteDatabaseApiKeyRequest) (*clusterauthv2.DeleteDatabaseApiKeyResponse, error)
}
FakeDatabaseApiKeyService is a test fake that implements DatabaseApiKeyServiceServer. Set the function fields to control responses per test.
func (*FakeDatabaseApiKeyService) CreateDatabaseApiKey ¶
func (f *FakeDatabaseApiKeyService) CreateDatabaseApiKey(ctx context.Context, req *clusterauthv2.CreateDatabaseApiKeyRequest) (*clusterauthv2.CreateDatabaseApiKeyResponse, error)
CreateDatabaseApiKey delegates to CreateDatabaseApiKeyFunc if set.
func (*FakeDatabaseApiKeyService) DeleteDatabaseApiKey ¶
func (f *FakeDatabaseApiKeyService) DeleteDatabaseApiKey(ctx context.Context, req *clusterauthv2.DeleteDatabaseApiKeyRequest) (*clusterauthv2.DeleteDatabaseApiKeyResponse, error)
DeleteDatabaseApiKey delegates to DeleteDatabaseApiKeyFunc if set.
func (*FakeDatabaseApiKeyService) ListDatabaseApiKeys ¶
func (f *FakeDatabaseApiKeyService) ListDatabaseApiKeys(ctx context.Context, req *clusterauthv2.ListDatabaseApiKeysRequest) (*clusterauthv2.ListDatabaseApiKeysResponse, error)
ListDatabaseApiKeys delegates to ListDatabaseApiKeysFunc if set.
type FakePlatformService ¶
type FakePlatformService struct {
platformv1.UnimplementedPlatformServiceServer
ListCloudProvidersFunc func(context.Context, *platformv1.ListCloudProvidersRequest) (*platformv1.ListCloudProvidersResponse, error)
ListCloudProviderRegionsFunc func(context.Context, *platformv1.ListCloudProviderRegionsRequest) (*platformv1.ListCloudProviderRegionsResponse, error)
}
FakePlatformService is a test fake that implements PlatformServiceServer. Set the function fields to control responses per test.
func (*FakePlatformService) ListCloudProviderRegions ¶
func (f *FakePlatformService) ListCloudProviderRegions(ctx context.Context, req *platformv1.ListCloudProviderRegionsRequest) (*platformv1.ListCloudProviderRegionsResponse, error)
ListCloudProviderRegions delegates to ListCloudProviderRegionsFunc if set.
func (*FakePlatformService) ListCloudProviders ¶
func (f *FakePlatformService) ListCloudProviders(ctx context.Context, req *platformv1.ListCloudProvidersRequest) (*platformv1.ListCloudProvidersResponse, error)
ListCloudProviders delegates to ListCloudProvidersFunc if set.
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
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.