Crossplane Function Test Framework
A Go library that allows easy implementation of unit tests for Crossplane functions written in Go.
Usage
Example Go test that runs a function in a blackbox test and compares the received with the expected output:
package account
import (
_ "embed"
"testing"
"github.com/crossplane/function-sdk-go/logging"
fntesting "github.com/dbinfrago/crossplane-function-test-framework"
"github.com/my-group/my-project/function"
)
var (
observedComposite []byte
observedComposed []byte
expectComposed []byte
expectComposite []byte
)
const (
subroutineName = "test-routine"
)
func TestSuccess(t *testing.T) {
log := logging.NewNopLogger()
fn := function.NewFunction(log)
fntesting.TestFunction(
t, fn,
fntesting.WithObservedCompositeYAML(observedComposite),
fntesting.WithObservedResourcesYAML(observedComposed),
fntesting.ExpectDesiredCompositeYAML(expectComposite),
fntesting.ExpectDesiredResourcesYAML(expectComposed),
)
}
Contributing
See our Contributing Guidelines.
Licensing
Each file contains a license reference to one of the included licenses.