@@ -73,6 +73,35 @@ func Test_hibernation(t *testing.T) {
7373 })
7474}
7575
76+ func Test_enablePDB (t * testing.T ) {
77+ svc , comp := getSvcCompCnpg (t )
78+ ctx := context .TODO ()
79+
80+ t .Run ("PDB disabled for single instance" , func (t * testing.T ) {
81+ comp .Spec .Parameters .Instances = 1
82+
83+ values , err := createCnpgHelmValues (ctx , svc , comp )
84+ assert .NoError (t , err )
85+ assert .Equal (t , false , values ["cluster" ].(map [string ]any )["enablePDB" ])
86+ })
87+
88+ t .Run ("PDB enabled for multiple instances" , func (t * testing.T ) {
89+ comp .Spec .Parameters .Instances = 2
90+
91+ values , err := createCnpgHelmValues (ctx , svc , comp )
92+ assert .NoError (t , err )
93+ assert .Equal (t , true , values ["cluster" ].(map [string ]any )["enablePDB" ])
94+ })
95+
96+ t .Run ("PDB disabled for paused instance" , func (t * testing.T ) {
97+ comp .Spec .Parameters .Instances = 0
98+
99+ values , err := createCnpgHelmValues (ctx , svc , comp )
100+ assert .NoError (t , err )
101+ assert .Equal (t , false , values ["cluster" ].(map [string ]any )["enablePDB" ])
102+ })
103+ }
104+
76105func Test_version (t * testing.T ) {
77106 svc , comp := getSvcCompCnpg (t )
78107 ctx := context .TODO ()
0 commit comments