Documentation
¶
Overview ¶
Package testutils provides test utility functions for the CLI package
Index ¶
- func CreateTestKubeconfig(t *testing.T, namespace string) string
- func CreateTestRecord(clock clockwork.Clock, name, uid, namespace string, ...) *pb.Record
- func ExecuteCommand(c *cobra.Command, args ...string) (string, error)
- func MockRESTClientFromRecords(records []*pb.Record) (*client.RESTClient, error)
- func ReadKubeconfigExtension(t *testing.T, kubeconfigPath, extensionName string, target interface{}) (bool, error)
- func ReadKubeconfigExtensionRaw(t *testing.T, kubeconfigPath, extensionName string) ([]byte, error)
- func TimePtr(t time.Time) *time.Time
- func UpdateKubeconfigNamespace(t *testing.T, kubeconfigPath, newNamespace string)
- type Params
- func (p *Params) APIPath() string
- func (p *Params) Host() string
- func (p *Params) KubeConfigPath() string
- func (p *Params) KubeContext() string
- func (p *Params) Namespace() string
- func (p *Params) RESTClient() *client.RESTClient
- func (p *Params) SetAPIPath(path string)
- func (p *Params) SetHost(host string)
- func (p *Params) SetKubeConfigPath(path string)
- func (p *Params) SetKubeContext(context string)
- func (p *Params) SetNamespace(ns string)
- func (p *Params) SetRESTClient(client *client.RESTClient)
- func (p *Params) SetSkipTLSVerify(skip bool)
- func (p *Params) SetToken(token string)
- func (p *Params) SkipTLSVerify() bool
- func (p *Params) Token() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTestKubeconfig ¶
CreateTestKubeconfig creates a temporary kubeconfig file for testing If namespace is empty, no namespace is set in the context
func CreateTestRecord ¶ added in v0.17.0
func CreateTestRecord(clock clockwork.Clock, name, uid, namespace string, startTime, endTime *time.Time, conditionStatus string, labels map[string]string) *pb.Record
CreateTestRecord creates a test record with all possible options Use empty string for namespace to use default, nil for labels to omit them
func ExecuteCommand ¶ added in v0.17.0
ExecuteCommand executes the root command passing the args and returns the output as a string and error
func MockRESTClientFromRecords ¶ added in v0.17.0
func MockRESTClientFromRecords(records []*pb.Record) (*client.RESTClient, error)
MockRESTClientFromRecords creates a mock REST client with comprehensive filtering support
func ReadKubeconfigExtension ¶
func ReadKubeconfigExtension(t *testing.T, kubeconfigPath, extensionName string, target interface{}) (bool, error)
ReadKubeconfigExtension reads and unmarshals a kubeconfig extension into the provided target The target parameter should be a pointer to the struct you want to unmarshal into Returns true if the extension was found and unmarshaled successfully, false if not found
func ReadKubeconfigExtensionRaw ¶
ReadKubeconfigExtensionRaw reads the tekton-results extension from a kubeconfig file as raw data This avoids import cycles by not depending on config package types
func UpdateKubeconfigNamespace ¶ added in v0.17.0
UpdateKubeconfigNamespace updates the namespace of the current context in a kubeconfig file
Types ¶
type Params ¶ added in v0.17.0
type Params struct {
// contains filtered or unexported fields
}
Params implements common.Params interface for testing This allows injecting fake/mock clients during tests
func NewParams ¶ added in v0.17.0
func NewParams() *Params
NewParams creates a new test Params with sensible defaults
func (*Params) KubeConfigPath ¶ added in v0.17.0
KubeConfigPath returns the kubeconfig file path
func (*Params) KubeContext ¶ added in v0.17.0
KubeContext returns the kubernetes context
func (*Params) RESTClient ¶ added in v0.17.0
func (p *Params) RESTClient() *client.RESTClient
RESTClient returns the injected REST client for testing
func (*Params) SetAPIPath ¶ added in v0.17.0
SetAPIPath sets the API path
func (*Params) SetKubeConfigPath ¶ added in v0.17.0
SetKubeConfigPath sets the kubeconfig file path
func (*Params) SetKubeContext ¶ added in v0.17.0
SetKubeContext sets the kubernetes context
func (*Params) SetNamespace ¶ added in v0.17.0
SetNamespace sets the kubernetes namespace, preserving default if empty
func (*Params) SetRESTClient ¶ added in v0.17.0
func (p *Params) SetRESTClient(client *client.RESTClient)
SetRESTClient injects a REST client for testing purposes
func (*Params) SetSkipTLSVerify ¶ added in v0.17.0
SetSkipTLSVerify sets whether to skip TLS verification
func (*Params) SkipTLSVerify ¶ added in v0.17.0
SkipTLSVerify returns whether to skip TLS verification