Skip to content

Commit

Permalink
Add UID to fake Operator objects in tests (#523)
Browse files Browse the repository at this point in the history
The code we test relies on UID and having UID set will
ensure greater correctness of our tests.

Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
m1kola authored Nov 8, 2023
1 parent e9fd250 commit b5c6bc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/resolution/variablesources/bundle_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/operator-framework/operator-controller/internal/resolution/variablesources"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/utils/pointer"

"github.com/operator-framework/deppy/pkg/deppy"
Expand All @@ -26,6 +27,10 @@ func fakeOperator(name, packageName string, upgradeConstraintPolicy operatorsv1a
return operatorsv1alpha1.Operator{
ObjectMeta: metav1.ObjectMeta{
Name: name,
// We manually set a fake UID here because the code we test
// uses UID to determine Operator CR which
// owns `BundleDeployment`
UID: uuid.NewUUID(),
},
Spec: operatorsv1alpha1.OperatorSpec{
PackageName: packageName,
Expand Down
5 changes: 5 additions & 0 deletions internal/resolution/variablesources/installed_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/utils/pointer"

Expand Down Expand Up @@ -207,6 +208,10 @@ func TestMakeInstalledPackageVariables(t *testing.T) {
return operatorsv1alpha1.Operator{
ObjectMeta: metav1.ObjectMeta{
Name: name,
// We manually set a fake UID here because the code we test
// uses UID to determine Operator CR which
// owns `BundleDeployment`
UID: uuid.NewUUID(),
},
Spec: operatorsv1alpha1.OperatorSpec{
PackageName: packageName,
Expand Down

0 comments on commit b5c6bc9

Please sign in to comment.