testcrd

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 10 Imported by: 0

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

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

Load CRD from a byte buffer

func (*ResourceAsserter) LoadFromFiles

func (a *ResourceAsserter) LoadFromFiles(crdPaths []string) error

type TestingT

type TestingT interface {
	Errorf(format string, args ...interface{})
}

TestingT is an interface wrapper around *testing.T

Jump to

Keyboard shortcuts

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