Skip to content

Commit 2e2c295

Browse files
RoddieKieleyCursor claude-4
andcommitted
Fix failing single test and operator deployment from custom helm chart values. (#1063)
* Fix TestDefaultPlatformDetector_DetectPlatform test for case when OPERATOR_OPENSHIFT env var is true. * Add empty runAsUser to values-openshift.yaml to allow OpenShift to set it. Signed-off-by: Roddie Kieley <[email protected]> Co-authored-by: Cursor claude-4 <[email protected]>
1 parent 7177140 commit 2e2c295

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

deploy/charts/operator/values-openshift.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ operator:
5050
allowPrivilegeEscalation: false
5151
readOnlyRootFilesystem: true
5252
runAsNonRoot: true
53+
runAsUser:
5354
capabilities:
5455
drop:
5556
- ALL

pkg/container/kubernetes/common_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,23 @@ func TestDefaultPlatformDetector_DetectPlatform(t *testing.T) {
6060
Host: "http://localhost:12345", // Non-existent endpoint
6161
}
6262

63-
// The first call should return an error
63+
// The first call should return either an error or success based on environment
6464
platform1, err1 := detector.DetectPlatform(config)
65-
assert.Error(t, err1)
66-
assert.Equal(t, PlatformKubernetes, platform1) // Default value when error occurs
6765

68-
// The second call should return the same error (cached)
66+
// The second call should return the same result (cached)
6967
platform2, err2 := detector.DetectPlatform(config)
70-
assert.Error(t, err2)
68+
69+
// Verify that both calls return the same result (caching works)
7170
assert.Equal(t, platform1, platform2)
72-
assert.Equal(t, err1.Error(), err2.Error())
71+
72+
// Verify error consistency
73+
if err1 != nil {
74+
assert.Error(t, err2, "Both calls should return the same error state")
75+
assert.Equal(t, err1.Error(), err2.Error())
76+
assert.Equal(t, PlatformKubernetes, platform1) // Default value when error occurs
77+
} else {
78+
assert.NoError(t, err2, "Both calls should return the same error state")
79+
// When OPERATOR_OPENSHIFT=true, we expect OpenShift platform
80+
assert.Equal(t, PlatformOpenShift, platform1)
81+
}
7382
}

0 commit comments

Comments
 (0)