Skip to content

Commit 2d47d1e

Browse files
author
Tyler Slaton
committed
address code review
1 parent fb9f7b5 commit 2d47d1e

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Diff for: pkg/controller/operators/openshift/clusteroperator_controller_test.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ var _ = Describe("ClusterOperator controller", func() {
121121
}))
122122

123123
By("setting upgradeable=false when there's an error determining compatibility")
124-
125-
By("changing the openshift environment variable to be invalid and restarting the ClusterOperator")
126-
resetCurrentReleaseTo("")
124+
Expect(resetCurrentReleaseTo("")).To(Succeed())
127125
Eventually(func() error {
128126
return k8sClient.Delete(ctx, co)
129127
}).Should(Succeed())
@@ -139,8 +137,7 @@ var _ = Describe("ClusterOperator controller", func() {
139137
LastTransitionTime: fixedNow(),
140138
}))
141139

142-
By("setting an appropriate variable for the cluster version and restarting the ClusterOperator")
143-
resetCurrentReleaseTo(clusterVersion)
140+
Expect(resetCurrentReleaseTo(clusterVersion)).To(Succeed())
144141
Eventually(func() error {
145142
return k8sClient.Delete(ctx, co)
146143
}).Should(Succeed())
@@ -306,10 +303,10 @@ var _ = Describe("ClusterOperator controller", func() {
306303
// resetCurrentRelease thread safely updates the currentRelease.version and then sets the openshift release
307304
// env var to the desired version. WARNING: This function should only be used for testing purposes as it
308305
// goes around the desired logic of only setting the version of the cluster for this operator once.
309-
func resetCurrentReleaseTo(version string) {
306+
func resetCurrentReleaseTo(version string) error {
310307
currentRelease.mu.Lock()
311308
defer currentRelease.mu.Unlock()
312309

313310
currentRelease.version = nil
314-
os.Setenv(releaseEnvVar, version)
311+
return os.Setenv(releaseEnvVar, version)
315312
}

Diff for: pkg/controller/operators/openshift/helpers_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ func TestIncompatibleOperators(t *testing.T) {
464464
scheme := runtime.NewScheme()
465465
require.NoError(t, AddToScheme(scheme))
466466

467-
fcli := fake.NewClientBuilder().WithObjects(objs...).WithScheme(scheme).Build()
467+
fcli := fake.NewClientBuilder().WithScheme(scheme).WithObjects(objs...).Build()
468468
incompatible, err := incompatibleOperators(context.Background(), fcli)
469469
if tt.expect.err {
470470
require.Error(t, err)

0 commit comments

Comments
 (0)