From 37c3cc9fba472ed5cfca2a4ede9468ed218e7d7c Mon Sep 17 00:00:00 2001 From: Blaine Gardner Date: Tue, 17 Dec 2024 12:21:50 -0700 Subject: [PATCH] test: ignore rgw cli flag order in unit test In the unit test that ensures `rgwCommandFlags` works properly, ignore the ordering of the flags. Golang maps are used underneath, which results in random flag ordering. This is fine as long as the `rgwCommandFlags` are still guaranteed to be appended to the args Rook normally applies. Signed-off-by: Blaine Gardner --- pkg/operator/ceph/object/spec_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/operator/ceph/object/spec_test.go b/pkg/operator/ceph/object/spec_test.go index 548e631da..b7892cd4b 100644 --- a/pkg/operator/ceph/object/spec_test.go +++ b/pkg/operator/ceph/object/spec_test.go @@ -982,10 +982,12 @@ func TestRgwCommandFlags(t *testing.T) { } rgwContainer, err := c.makeDaemonContainer(rgwConfig) assert.NoError(t, err) + // ordering of additional args amongst themselves doesn't matter (and is random b/c of + // underlying map data type), but it is still important that the additional args are always + // after the args Rook normally applies l := len(rgwContainer.Args) - assert.Equal(t, "--rgw-option=val spaced", rgwContainer.Args[l-3]) - assert.Equal(t, "--rgw-option=val-dashed", rgwContainer.Args[l-2]) - assert.Equal(t, "--rgw-option=val_underscored", rgwContainer.Args[l-1]) + addedArgs := rgwContainer.Args[l-3:] + assert.ElementsMatch(t, []string{"--rgw-option=val spaced", "--rgw-option=val-dashed", "--rgw-option=val_underscored"}, addedArgs) }) }