README ¶
testcrd
Unit test your Kubernetes Custom Resource Definitions (CRDs) against concreate resource samples without a need for a running Kubernetes cluster.
The primary use case would be to ensure backward-compatibility of CRD changes.
Installation
go get github.com/roma-glushko/testcrd
Usage
import (
"github.com/roma-glushko/testcrd"
"testing"
)
func TestCRD_AssertDefinitionBackwardCompatible(t *testing.T) {
asserter := testcrd.NewResourceAsserter()
_ = asserter.LoadFromFiles([]string{
"crd/my_crd.yaml",
})
_ = asserter.AssertFiles(t, []string{
"fixtures/my_crd/resource.sample.yaml",
})
}
Documentation ¶
Index ¶
- type ResourceAsserter
- func (a *ResourceAsserter) Assert(t TestingT, resource *unstructured.Unstructured) error
- func (a *ResourceAsserter) AssertFiles(t TestingT, resourcePaths []string) error
- func (a *ResourceAsserter) Load(crds []*apiextensions.CustomResourceDefinition) error
- func (a *ResourceAsserter) LoadFromFiles(crdPaths []string) error
- type TestingT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResourceAsserter ¶
type ResourceAsserter struct {
// contains filtered or unexported fields
}
func NewResourceAsserter ¶
func NewResourceAsserter() *ResourceAsserter
func (*ResourceAsserter) Assert ¶
func (a *ResourceAsserter) Assert(t TestingT, resource *unstructured.Unstructured) error
func (*ResourceAsserter) AssertFiles ¶
func (a *ResourceAsserter) AssertFiles(t TestingT, resourcePaths []string) error
func (*ResourceAsserter) Load ¶
func (a *ResourceAsserter) Load(crds []*apiextensions.CustomResourceDefinition) error
Load CRD from a byte buffer
func (*ResourceAsserter) LoadFromFiles ¶
func (a *ResourceAsserter) LoadFromFiles(crdPaths []string) error
Click to show internal directories.
Click to hide internal directories.