Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

github.com/dbinfrago/crossplane-function-test-framework

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/dbinfrago/crossplane-function-test-framework

Source
Go
Version
v1.0.0
Version published
Created
Source

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 (
	//go:embed testdata/arg_composite.yaml
	observedComposite []byte
	//go:embed testdata/arg_observed_composed.yaml
	observedComposed []byte

	//go:embed testdata/expect_composed.yaml
	expectComposed []byte
	//go:embed testdata/expect_composite.yaml
	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.

FAQs

Package last updated on 11 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts