fake

package
v0.7.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: Apache-2.0 Imports: 18 Imported by: 275

Documentation

Overview

Package fake provides a fake client for testing.

A fake client is backed by its simple object store indexed by GroupVersionResource. You can create a fake client with optional objects.

client := NewFakeClientWithScheme(scheme, initObjs...) // initObjs is a slice of runtime.Object

You can invoke the methods defined in the Client interface.

When in doubt, it's almost always better not to use this package and instead use envtest.Environment with a real client and API server.

WARNING: ⚠️ Current Limitations / Known Issues with the fake Client ⚠️

  • This client does not have a way to inject specific errors to test handled vs. unhandled errors.
  • There is some support for sub resources which can cause issues with tests if you're trying to update e.g. metadata and status in the same reconcile.
  • No OpeanAPI validation is performed when creating or updating objects.
  • ObjectMeta's `Generation` and `ResourceVersion` don't behave properly, Patch or Update

operations that rely on these fields will fail, or give false positives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeClient

func NewFakeClient(initObjs ...client.Object) client.Client

NewFakeClient creates a new fake client for testing. You can choose to initialize it with a slice of runtime.Object.

func NewFakeClientWithScheme added in v0.1.8

func NewFakeClientWithScheme(clientScheme *runtime.Scheme, initObjs ...client.Object) client.Client

NewFakeClientWithScheme creates a new fake client with the given scheme for testing. You can choose to initialize it with a slice of runtime.Object.

Types

This section is empty.

Jump to

Keyboard shortcuts

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