Skip to content

Commit

Permalink
Test if AdHoc returns success False on command failure
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanMillerC committed Oct 12, 2022
1 parent 3c2309f commit 3f7b7bc
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions tests/step_implementers/shared/test_ad_hoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@

class TestAdHoc(BaseStepImplementerTestCase):

def test_run_step_fails_if_command_not_provided(self):
def test_run_step_with_command(self):
with TempDirectory() as test_dir:

# GIVEN a step implementer configured like:
step_implementer = self.create_step_implementer(test_dir, {})
config = {
'command': 'echo "Hello World!"'
}
step_implementer = self.create_step_implementer(test_dir, config)

# WHEN I run the step
step_result = step_implementer._run_step()

# THEN it should return a StepResult
self.assertIsNotNone(step_result)

# AND the StepResult should have an artifact with the default message
self.assertEqual(step_result.success, False)
# AND the StepResult should have an artifact with the command-output
self.assertIsNotNone(step_result.get_artifact('command-output').value)

def test_run_step_with_command(self):
def test_run_step_fails_if_command_fails(self):
with TempDirectory() as test_dir:

# GIVEN a step implementer configured like:
# GIVEN a step implementer configured with a command that will fail
config = {
'command': 'echo "Hello World!"'
'command': 'echooo "Hello World!"'
}
step_implementer = self.create_step_implementer(test_dir, config)

Expand All @@ -39,9 +42,23 @@ def test_run_step_with_command(self):
# THEN it should return a StepResult
self.assertIsNotNone(step_result)

# AND the StepResult should have an artifact with the default message
self.assertIsNotNone(step_result.get_artifact('command-output').value)
# AND the StepResult should be marked success False
self.assertEqual(step_result.success, False)

def test_run_step_fails_if_command_not_provided(self):
with TempDirectory() as test_dir:

# GIVEN a step implementer configured like:
step_implementer = self.create_step_implementer(test_dir, {})

# WHEN I run the step
step_result = step_implementer._run_step()

# THEN it should return a StepResult
self.assertIsNotNone(step_result)

# AND the StepResult should be marked success False
self.assertEqual(step_result.success, False)

def test__required_config_or_result_keys(self):
required_keys = AdHoc._required_config_or_result_keys()
Expand Down

0 comments on commit 3f7b7bc

Please sign in to comment.