Skip to content

Commit 30a70f5

Browse files
committed
fix unit-test
1 parent 0434c39 commit 30a70f5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

cmd/postgres-operator/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ func initManager(ctx context.Context) (runtime.Options, error) {
276276
options.LeaderElection = true
277277
options.LeaderElectionID = lease
278278
options.LeaderElectionNamespace = os.Getenv("PGO_NAMESPACE")
279+
} else {
280+
// K8SPG-761
281+
options.LeaderElection = true
282+
options.LeaderElectionID = perconaRuntime.ElectionID
279283
}
280284

281285
// Check PGO_TARGET_NAMESPACE for backwards compatibility with
@@ -315,10 +319,6 @@ func initManager(ctx context.Context) (runtime.Options, error) {
315319
}
316320
}
317321

318-
// K8SPG-761
319-
options.LeaderElection = true
320-
options.LeaderElectionID = perconaRuntime.ElectionID
321-
322322
return options, nil
323323
}
324324

cmd/postgres-operator/main_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ func TestInitManager(t *testing.T) {
3232
})
3333

3434
assert.Assert(t, options.Cache.DefaultNamespaces == nil)
35-
assert.Assert(t, options.LeaderElection == false)
35+
assert.Assert(t, options.LeaderElection == true)
3636

3737
{
3838
options.Cache.SyncPeriod = nil
3939
options.Controller.GroupKindConcurrency = nil
4040
options.HealthProbeBindAddress = ""
41+
options.LeaderElection = false
42+
options.LeaderElectionID = ""
4143

4244
assert.Assert(t, reflect.ValueOf(options).IsZero(),
4345
"expected remaining fields to be unset:\n%+v", options)

0 commit comments

Comments
 (0)