Documentation ¶
Overview ¶
testing package provides structure and functions useful for create test and have predictable outcome or avoid to call real external dependencies
Index ¶
- Variables
- func DefaultHeaders() http.Header
- func ReadBytesFromFile(t *testing.T, path string) []byte
- func UnstructuredFromFile(t *testing.T, path string) *unstructured.Unstructured
- type TestClientFactory
- func (f *TestClientFactory) DynamicClient() (dynamic.Interface, error)
- func (f *TestClientFactory) KubernetesClientSet() (kubernetes.Interface, error)
- func (f *TestClientFactory) ToRESTConfig() (*rest.Config, error)
- func (f *TestClientFactory) ToRESTMapper() (meta.RESTMapper, error)
- func (f *TestClientFactory) UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)
- func (f *TestClientFactory) WithNamespace(ns string) *TestClientFactory
Constants ¶
This section is empty.
Variables ¶
var ( // Scheme is the default instance of runtime.Scheme to which types in the Kubernetes API are already registered Scheme = runtime.NewScheme() // Codecs provides access to encoding and decoding for the scheme Codecs = serializer.NewCodecFactory(Scheme) )
Functions ¶
func DefaultHeaders ¶
DefaultHeaders return a base http.Header configured to mimik an api-server response headers
func ReadBytesFromFile ¶
ReadBytesFromFile wrap the login of reading raw bytes from a file at path
func UnstructuredFromFile ¶
func UnstructuredFromFile(t *testing.T, path string) *unstructured.Unstructured
UnstructuredFromFile returns an Unstructured resource reading it from file at path
Types ¶
type TestClientFactory ¶
type TestClientFactory struct { util.ClientFactory // Client custom RESTClient implementation to return in UnstructuredClientForMapping and used in KubernetesClientSet Client resource.RESTClient // UnstructuredClientForMappingFunc custom function to call when UnstructuredClientForMapping is invoked UnstructuredClientForMappingFunc resource.FakeClientFunc // RESTMapper custom RESTMapper implementation that can be used to augment the supported default types RESTMapper meta.RESTMapper // FakeDynamicClient custom fake dynamic client implementation to return in DynamicClient FakeDynamicClient *fakedynamic.FakeDynamicClient // contains filtered or unexported fields }
TestClientFactory extends Factory and provides fake implementation, and affordances for working with kubernetes packages
func NewTestClientFactory ¶
func NewTestClientFactory() *TestClientFactory
NewTestClientFactory return a new TestFactory with a clientgetter that doesn't read from on disk data
func (*TestClientFactory) DynamicClient ¶
func (f *TestClientFactory) DynamicClient() (dynamic.Interface, error)
DynamicClient reimplement the method for returning a simple fake Dynamic client or a custom one if available
func (*TestClientFactory) KubernetesClientSet ¶
func (f *TestClientFactory) KubernetesClientSet() (kubernetes.Interface, error)
KubernetesClientSet reimplement the method for returning only selected kubernetes clients with fake client
func (*TestClientFactory) ToRESTConfig ¶
func (f *TestClientFactory) ToRESTConfig() (*rest.Config, error)
ToRESTConfig reimplement the method for returning a fake clientConfig
func (*TestClientFactory) ToRESTMapper ¶ added in v0.4.0
func (f *TestClientFactory) ToRESTMapper() (meta.RESTMapper, error)
ToRESTMapper reimplement the method for returning a custom mapper
func (*TestClientFactory) UnstructuredClientForMapping ¶
func (f *TestClientFactory) UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error)
UnstructuredClientForMapping reimplement the method for returning the custom client set on the test factory
func (*TestClientFactory) WithNamespace ¶
func (f *TestClientFactory) WithNamespace(ns string) *TestClientFactory
WithNamespace is used to mention namespace reactively