roma-glushko / testcrd

Unit test your Kubernetes Custom Resource Definitions (CRDs) 🛠️

Home Page:https://pkg.go.dev/github.com/roma-glushko/testcrd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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",
	})
}

About

Unit test your Kubernetes Custom Resource Definitions (CRDs) 🛠️

https://pkg.go.dev/github.com/roma-glushko/testcrd

License:MIT License


Languages

Language:Go 98.3%Language:Makefile 1.7%