Skip to content

Commit 0b46af1

Browse files
committed
fix(tests): correct mock responses to match shell detection logic
The detect_available_shell() function checks for 'test' in response, not 'exists'. Updated all test mocks to return 'test' instead of 'exists' to match the implementation's expectations. Changes: - test_detect_available_shell_finds_bash: 'exists' -> 'test' - test_detect_available_shell_fallback_to_sh: 'exists' -> 'test' - test_detect_available_shell_fallback_to_busybox: 'exists' -> 'test' - test_exec_with_shell_fallback_detects_persistent_shell_error: 'exists' -> 'test' - test_exec_with_shell_fallback_retries_on_error: 'exists' -> 'test' - test_exec_with_shell_fallback_fails_after_max_retries: 'exists' -> 'test' This ensures tests properly validate the shell detection and fallback logic. Signed-off-by: NETIZEN-11 <niteshkumar121411@gmail.com>
1 parent 2ccd2f6 commit 0b46af1

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tests/test_time_actions_scenario_plugin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_run_with_skew_time_exception(self, mock_yaml, mock_open):
125125
def test_detect_available_shell_finds_bash(self):
126126
"""Test shell detection finds /bin/bash"""
127127
kubecli_mock = MagicMock()
128-
kubecli_mock.exec_cmd_in_pod.return_value = "exists"
128+
kubecli_mock.exec_cmd_in_pod.return_value = "test" # Changed from "exists"
129129

130130
shell = self.plugin.detect_available_shell(
131131
"pod1", "ns1", "container1", kubecli_mock
@@ -140,7 +140,7 @@ def test_detect_available_shell_fallback_to_sh(self):
140140
# First call (bash) fails, second call (sh) succeeds
141141
kubecli_mock.exec_cmd_in_pod.side_effect = [
142142
"bash: not found", # bash fails
143-
"exists" # sh succeeds
143+
"test" # sh succeeds - Changed from "exists"
144144
]
145145

146146
shell = self.plugin.detect_available_shell(
@@ -157,7 +157,7 @@ def test_detect_available_shell_fallback_to_busybox(self):
157157
kubecli_mock.exec_cmd_in_pod.side_effect = [
158158
"bash: not found", # bash fails
159159
"sh: not found", # sh fails
160-
"exists" # busybox succeeds
160+
"test" # busybox succeeds - Changed from "exists"
161161
]
162162

163163
shell = self.plugin.detect_available_shell(
@@ -266,7 +266,7 @@ def test_exec_with_shell_fallback_detects_persistent_shell_error(self):
266266
kubecli_mock = MagicMock()
267267
# Shell detection succeeds, but execution still fails with shell error
268268
kubecli_mock.exec_cmd_in_pod.side_effect = [
269-
"exists", # Shell detection succeeds
269+
"test", # Shell detection succeeds - Changed from "exists"
270270
"impossible to determine the shell" # But execution fails
271271
]
272272

@@ -284,7 +284,7 @@ def test_exec_with_shell_fallback_retries_on_error(self):
284284
kubecli_mock = MagicMock()
285285
# First few attempts fail, last one succeeds
286286
kubecli_mock.exec_cmd_in_pod.side_effect = [
287-
"exists", # Shell detection
287+
"test", # Shell detection - Changed from "exists"
288288
"exec failed: connection reset", # Attempt 1
289289
"error: timeout", # Attempt 2
290290
"success" # Attempt 3
@@ -304,7 +304,7 @@ def test_exec_with_shell_fallback_fails_after_max_retries(self):
304304
kubecli_mock = MagicMock()
305305
# All attempts fail
306306
kubecli_mock.exec_cmd_in_pod.side_effect = [
307-
"exists", # Shell detection
307+
"test", # Shell detection - Changed from "exists"
308308
"error", # Attempt 1
309309
"error", # Attempt 2
310310
"error", # Attempt 3

0 commit comments

Comments
 (0)