@@ -13,13 +13,12 @@ import (
1313 "testing"
1414
1515 "gotest.tools/v3/assert"
16- "gotest.tools/v3/assert/cmp"
1716 corev1 "k8s.io/api/core/v1"
1817 "k8s.io/apimachinery/pkg/api/resource"
19- "sigs.k8s.io/yaml"
2018
2119 "github.com/crunchydata/postgres-operator/internal/initialize"
2220 "github.com/crunchydata/postgres-operator/internal/naming"
21+ "github.com/crunchydata/postgres-operator/internal/testing/cmp"
2322 "github.com/crunchydata/postgres-operator/internal/testing/require"
2423 "github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
2524)
@@ -213,13 +212,13 @@ pg1-socket-path = /tmp/postgres
213212 []string {"some-instance" })
214213
215214 assert .Assert (t ,
216- strings .Contains (configmap .Data ["pgbackrest_instance.conf" ],
215+ cmp .Contains (configmap .Data ["pgbackrest_instance.conf" ],
217216 "archive-header-check = n" ))
218217 assert .Assert (t ,
219- strings .Contains (configmap .Data ["pgbackrest_instance.conf" ],
218+ cmp .Contains (configmap .Data ["pgbackrest_instance.conf" ],
220219 "page-header-check = n" ))
221220 assert .Assert (t ,
222- strings .Contains (configmap .Data ["pgbackrest_instance.conf" ],
221+ cmp .Contains (configmap .Data ["pgbackrest_instance.conf" ],
223222 "pg-version-force" ))
224223
225224 cluster .Spec .Backups .PGBackRest .Repos = []v1beta1.PGBackRestRepo {
@@ -234,13 +233,13 @@ pg1-socket-path = /tmp/postgres
234233 []string {"some-instance" })
235234
236235 assert .Assert (t ,
237- strings .Contains (configmap .Data ["pgbackrest_repo.conf" ],
236+ cmp .Contains (configmap .Data ["pgbackrest_repo.conf" ],
238237 "archive-header-check = n" ))
239238 assert .Assert (t ,
240- strings .Contains (configmap .Data ["pgbackrest_repo.conf" ],
239+ cmp .Contains (configmap .Data ["pgbackrest_repo.conf" ],
241240 "page-header-check = n" ))
242241 assert .Assert (t ,
243- strings .Contains (configmap .Data ["pgbackrest_repo.conf" ],
242+ cmp .Contains (configmap .Data ["pgbackrest_repo.conf" ],
244243 "pg-version-force" ))
245244 })
246245}
@@ -323,10 +322,8 @@ func TestReloadCommand(t *testing.T) {
323322}
324323
325324func TestReloadCommandPrettyYAML (t * testing.T ) {
326- b , err := yaml .Marshal (reloadCommand ("any" ))
327- assert .NilError (t , err )
328- assert .Assert (t , strings .Contains (string (b ), "\n - |" ),
329- "expected literal block scalar, got:\n %s" , b )
325+ assert .Assert (t , cmp .MarshalContains (reloadCommand ("any" ), "\n - |" ),
326+ "expected literal block scalar" )
330327}
331328
332329func TestRestoreCommand (t * testing.T ) {
@@ -351,19 +348,21 @@ func TestRestoreCommand(t *testing.T) {
351348}
352349
353350func TestRestoreCommandPrettyYAML (t * testing.T ) {
354- b , err := yaml .Marshal (RestoreCommand ("/dir" , "try" , "" , nil , "--options" ))
355-
356- assert .NilError (t , err )
357- assert .Assert (t , strings .Contains (string (b ), "\n - |" ),
358- "expected literal block scalar, got:\n %s" , b )
351+ assert .Assert (t ,
352+ cmp .MarshalContains (
353+ RestoreCommand ("/dir" , "try" , "" , nil , "--options" ),
354+ "\n - |" ,
355+ ),
356+ "expected literal block scalar" )
359357}
360358
361359func TestRestoreCommandTDE (t * testing.T ) {
362- b , err := yaml .Marshal (RestoreCommand ("/dir" , "try" , "echo testValue" , nil , "--options" ))
363-
364- assert .NilError (t , err )
365- assert .Assert (t , strings .Contains (string (b ), "encryption_key_command = 'echo testValue'" ),
366- "expected encryption_key_command setting, got:\n %s" , b )
360+ assert .Assert (t ,
361+ cmp .MarshalContains (
362+ RestoreCommand ("/dir" , "try" , "echo testValue" , nil , "--options" ),
363+ "encryption_key_command = 'echo testValue'" ,
364+ ),
365+ "expected encryption_key_command setting" )
367366}
368367
369368func TestDedicatedSnapshotVolumeRestoreCommand (t * testing.T ) {
@@ -388,11 +387,12 @@ func TestDedicatedSnapshotVolumeRestoreCommand(t *testing.T) {
388387}
389388
390389func TestDedicatedSnapshotVolumeRestoreCommandPrettyYAML (t * testing.T ) {
391- b , err := yaml .Marshal (DedicatedSnapshotVolumeRestoreCommand ("/dir" , "--options" ))
392-
393- assert .NilError (t , err )
394- assert .Assert (t , strings .Contains (string (b ), "\n - |" ),
395- "expected literal block scalar, got:\n %s" , b )
390+ assert .Assert (t ,
391+ cmp .MarshalContains (
392+ DedicatedSnapshotVolumeRestoreCommand ("/dir" , "--options" ),
393+ "\n - |" ,
394+ ),
395+ "expected literal block scalar" )
396396}
397397
398398func TestServerConfig (t * testing.T ) {
0 commit comments