Skip to content

Commit bd39ddd

Browse files
committed
Added tests
Signed-off-by: desmax74 <mdessi@redhat.com>
1 parent 2dd26e6 commit bd39ddd

3 files changed

Lines changed: 42 additions & 32 deletions

File tree

test/e2e/cco_helm_rendering_test.go

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const (
3232
kindCredentialsReq = "CredentialsRequest"
3333
ccoSecretName = "test-release-cloud-creds"
3434
ccoNamespace = "openshift-cloud-credential-operator"
35+
testBucket = "trustify-storage"
36+
testRegionUSEast1 = "us-east-1"
3537
)
3638

3739
func testDatabaseValues() map[string]interface{} {
@@ -45,7 +47,7 @@ func testDatabaseValues() map[string]interface{} {
4547

4648
func awsValues() map[string]interface{} {
4749
return map[string]interface{}{
48-
fieldAppDomain: testAppDomain,
50+
fieldAppDomain: testAppDomain,
4951
fieldCloudProvider: "aws",
5052
fieldCloudCredentials: map[string]interface{}{
5153
"aws": map[string]interface{}{
@@ -58,20 +60,20 @@ func awsValues() map[string]interface{} {
5860
},
5961
},
6062
},
61-
"storage": map[string]interface{}{
62-
"type": "s3",
63-
"bucket": "trustify-storage",
64-
"region": "us-east-1",
63+
fieldStorage: map[string]interface{}{
64+
fieldType: "s3",
65+
fieldBucket: testBucket,
66+
fieldRegion: testRegionUSEast1,
6567
},
66-
"database": testDatabaseValues(),
67-
"metrics": map[string]interface{}{fieldEnabled: false},
68-
"tracing": map[string]interface{}{fieldEnabled: false},
68+
fieldDatabase: testDatabaseValues(),
69+
fieldMetrics: map[string]interface{}{fieldEnabled: false},
70+
fieldTracing: map[string]interface{}{fieldEnabled: false},
6971
}
7072
}
7173

7274
func gcpValues() map[string]interface{} {
7375
return map[string]interface{}{
74-
fieldAppDomain: testAppDomain,
76+
fieldAppDomain: testAppDomain,
7577
fieldCloudProvider: "gcp",
7678
fieldCloudCredentials: map[string]interface{}{
7779
"gcp": map[string]interface{}{
@@ -83,14 +85,14 @@ func gcpValues() map[string]interface{} {
8385
},
8486
},
8587
},
86-
"storage": map[string]interface{}{
87-
"type": "s3",
88-
"bucket": "trustify-storage",
89-
"region": "us-central1",
88+
fieldStorage: map[string]interface{}{
89+
fieldType: "s3",
90+
fieldBucket: testBucket,
91+
fieldRegion: "us-central1",
9092
},
91-
"database": testDatabaseValues(),
92-
"metrics": map[string]interface{}{fieldEnabled: false},
93-
"tracing": map[string]interface{}{fieldEnabled: false},
93+
fieldDatabase: testDatabaseValues(),
94+
fieldMetrics: map[string]interface{}{fieldEnabled: false},
95+
fieldTracing: map[string]interface{}{fieldEnabled: false},
9496
}
9597
}
9698

@@ -167,7 +169,8 @@ func TestHelmRenderAWSCredentialsRequest(t *testing.T) {
167169
providerSpec, _ := spec["providerSpec"].(map[string]interface{})
168170
require.NotNil(t, providerSpec, "providerSpec should exist")
169171
assert.Equal(t, "AWSProviderSpec", providerSpec["kind"], "providerSpec should be AWSProviderSpec")
170-
assert.Equal(t, "cloudcredential.openshift.io/v1", providerSpec[fieldAPIVersion], "providerSpec apiVersion should match")
172+
assert.Equal(t, "cloudcredential.openshift.io/v1",
173+
providerSpec[fieldAPIVersion], "providerSpec apiVersion should match")
171174

172175
entries, ok := providerSpec["statementEntries"].([]interface{})
173176
assert.True(t, ok, "statementEntries should be a list")
@@ -217,16 +220,16 @@ func TestHelmRenderNoCredentialsRequestWithoutCloudProvider(t *testing.T) {
217220
chartPath := getChartPath(t)
218221
values := map[string]interface{}{
219222
fieldAppDomain: testAppDomain,
220-
"storage": map[string]interface{}{
221-
"type": "s3",
222-
"bucket": "test-bucket",
223-
"region": "us-east-1",
223+
fieldStorage: map[string]interface{}{
224+
fieldType: "s3",
225+
fieldBucket: "test-bucket",
226+
fieldRegion: testRegionUSEast1,
224227
"accessKey": "test-key",
225228
"secretKey": "test-secret",
226229
},
227-
"database": testDatabaseValues(),
228-
"metrics": map[string]interface{}{fieldEnabled: false},
229-
"tracing": map[string]interface{}{fieldEnabled: false},
230+
fieldDatabase: testDatabaseValues(),
231+
fieldMetrics: map[string]interface{}{fieldEnabled: false},
232+
fieldTracing: map[string]interface{}{fieldEnabled: false},
230233
}
231234

232235
rendered := renderHelmChart(t, chartPath, values)
@@ -314,16 +317,16 @@ func TestHelmRenderStorageEnvVarsWithoutCCO(t *testing.T) {
314317
chartPath := getChartPath(t)
315318
values := map[string]interface{}{
316319
fieldAppDomain: testAppDomain,
317-
"storage": map[string]interface{}{
318-
"type": "s3",
319-
"bucket": "trustify-storage",
320-
"region": "us-east-1",
320+
fieldStorage: map[string]interface{}{
321+
fieldType: "s3",
322+
fieldBucket: testBucket,
323+
fieldRegion: testRegionUSEast1,
321324
"accessKey": "explicit-access-key",
322325
"secretKey": "explicit-secret-key",
323326
},
324-
"database": testDatabaseValues(),
325-
"metrics": map[string]interface{}{fieldEnabled: false},
326-
"tracing": map[string]interface{}{fieldEnabled: false},
327+
fieldDatabase: testDatabaseValues(),
328+
fieldMetrics: map[string]interface{}{fieldEnabled: false},
329+
fieldTracing: map[string]interface{}{fieldEnabled: false},
327330
}
328331

329332
rendered := renderHelmChart(t, chartPath, values)

test/e2e/helpers_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ const (
6161
fieldImporter = "importer"
6262
fieldIngress = "ingress"
6363
fieldHelm = "helm"
64+
fieldStorage = "storage"
65+
fieldDatabase = "database"
66+
fieldMetrics = "metrics"
67+
fieldTracing = "tracing"
68+
fieldType = "type"
69+
fieldBucket = "bucket"
70+
fieldRegion = "region"
6471

6572
// Common test skip messages.
6673
skipE2ETest = "skipping e2e test in short mode"

test/e2e/operator_health_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func TestOperatorMetricsEndpoint(t *testing.T) {
275275
assert.NotEmpty(t, service.Spec.Ports, "metrics service should have ports")
276276

277277
for _, port := range service.Spec.Ports {
278-
if port.Name == "https" || port.Name == "metrics" {
278+
if port.Name == "https" || port.Name == fieldMetrics {
279279
t.Logf("Metrics port: %s -> %d", port.Name, port.Port)
280280
}
281281
}

0 commit comments

Comments
 (0)