From e89c7b62b86285d4cb92f8a19958950483dd0de5 Mon Sep 17 00:00:00 2001 From: Pete Savage Date: Thu, 21 Sep 2023 18:15:44 +0100 Subject: [PATCH] Test for endpoint fix (#867) --- .../objectstore/appinterface_test.go | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/controllers/cloud.redhat.com/providers/objectstore/appinterface_test.go b/controllers/cloud.redhat.com/providers/objectstore/appinterface_test.go index b82dde820..d09c30059 100644 --- a/controllers/cloud.redhat.com/providers/objectstore/appinterface_test.go +++ b/controllers/cloud.redhat.com/providers/objectstore/appinterface_test.go @@ -87,3 +87,60 @@ func TestAppInterfaceObjectStore(t *testing.T) { assert.Equal(t, &expected, c) } + +func TestAppInterfaceBadBucket(t *testing.T) { + c := config.ObjectStoreConfig{ + Hostname: "original", + Buckets: []config.ObjectStoreBucket{{ + AccessKey: utils.StringPtr("access"), + Endpoint: utils.StringPtr("endpoint"), + Name: "badger", + Region: utils.StringPtr("region"), + RequestedName: "badger", + SecretKey: utils.StringPtr("secret"), + Tls: utils.TruePtr(), + }}, + } + err := resolveBucketDeps([]string{"test-bucket"}, &c) + + assert.Error(t, err) +} + +func TestAppInterfaceGoodAndBadBucket(t *testing.T) { + c := config.ObjectStoreConfig{ + Hostname: "original", + Buckets: []config.ObjectStoreBucket{ + { + AccessKey: utils.StringPtr("access"), + Endpoint: utils.StringPtr("endpoint"), + Name: "badger", + Region: utils.StringPtr("region"), + RequestedName: "badger", + SecretKey: utils.StringPtr("secret"), + Tls: utils.TruePtr(), + }, { + AccessKey: utils.StringPtr("access"), + Endpoint: utils.StringPtr("test-endpoint"), + Name: "test-bucket", + Region: utils.StringPtr("region"), + RequestedName: "test-bucket", + SecretKey: utils.StringPtr("secret"), + Tls: utils.TruePtr(), + }, + { + AccessKey: utils.StringPtr("access"), + Endpoint: utils.StringPtr("endpoint"), + Name: "badgerRage", + Region: utils.StringPtr("region"), + RequestedName: "badgerRage", + SecretKey: utils.StringPtr("secret"), + Tls: utils.TruePtr(), + }, + }, + } + err := resolveBucketDeps([]string{"test-bucket"}, &c) + + assert.NoError(t, err) + assert.Len(t, c.Buckets, 1) + assert.Equal(t, c.Hostname, "test-endpoint") +}