rukpak icon indicating copy to clipboard operation
rukpak copied to clipboard

Add unit tests for the provisioners

Open everettraven opened this issue 2 years ago • 1 comments

I noticed the Bundle and BundleDeployment provisioners under internal/provisioner don't have unit tests. We should implement some unit tests that are based on running the Reconcile() function for each provisioner. In the unit tests we could easily mock the Unpacker interface with something like:

var _ source.Unpacker = &MockSource{}

// MockSource is a utility for mocking out an Unpacker source
type MockSource struct {
	// result is the result that should be returned when MockSource.Unpack is called
	result *source.Result

	// shouldError determines whether or not the MockSource should return an error when MockSource.Unpack is called
	shouldError bool
}

func (ms *MockSource) Unpack(ctx context.Context, catalog *catalogdv1beta1.Catalog) (*source.Result, error) {
	if ms.shouldError {
		return nil, errors.New("mocksource error")
	}

	return ms.result, nil
}

We should also add unit tests to the plain, helm, and registry provisioners if they don't already have them.

The creation of this issue was inspired by https://github.com/operator-framework/catalogd/pull/65#discussion_r1198295542

everettraven avatar May 19 '23 14:05 everettraven

This issue has become stale because it has been open 60 days with no activity. The maintainers of this repo will remove this label during issue triage or it will be removed automatically after an update. Adding the lifecycle/frozen label will cause this issue to ignore lifecycle events.

github-actions[bot] avatar Jul 19 '23 00:07 github-actions[bot]