Skip to content

Commit bdbecf1

Browse files
author
Philip Hurst
committed
refactored test
1 parent c0291c9 commit bdbecf1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

internal/pgbouncer/reconcile_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,25 @@ func TestSCRAMVerifier(t *testing.T) {
106106
cluster.Spec.Proxy.PGBouncer = new(v1beta1.PGBouncerPodSpec)
107107
cluster.Default()
108108

109-
// Simulate the generation of SCRAM verifier
109+
// Simulate the setting of a password only
110110
existing.Data = map[string][]byte{
111-
"pgbouncer-verifier": []byte("SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey"),
111+
"pgbouncer-password": []byte("password"),
112112
}
113113

114+
// Verify that a SCRAM verifier is set
114115
assert.NilError(t, Secret(ctx, cluster, root, existing, service, intent))
115-
116-
// Verify that the SCRAM verifier is correctly set in the intent secret
117116
assert.Assert(t, len(intent.Data["pgbouncer-verifier"]) != 0)
117+
118+
// Simulate the setting of a password and a verifier
119+
intent = new(corev1.Secret)
120+
existing.Data = map[string][]byte{
121+
"pgbouncer-verifier": []byte("SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey"),
122+
"pgbouncer-password": []byte("password"),
123+
}
124+
assert.NilError(t, Secret(ctx, cluster, root, existing, service, intent))
118125
assert.Equal(t, string(intent.Data["pgbouncer-verifier"]), "SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey")
126+
assert.Equal(t, string(intent.Data["pgbouncer-password"]), "password")
127+
119128
}
120129

121130
func TestPod(t *testing.T) {

0 commit comments

Comments
 (0)