|
1 | 1 | from unittest import TestCase
|
2 | 2 | from unittest.mock import patch
|
| 3 | +from os import linesep |
3 | 4 |
|
4 | 5 | from aws_lambda_builders.workflows.ruby_bundler.bundler import SubprocessBundler, BundlerExecutionError
|
5 | 6 |
|
@@ -73,13 +74,32 @@ def test_bundle_file_removed_if_generated(self):
|
73 | 74 | self.osutils.get_bundle_dir.assert_called_once()
|
74 | 75 | self.osutils.remove_directory.assert_called_once()
|
75 | 76 |
|
76 |
| - def test_raises_BundlerExecutionError_with_err_text_if_retcode_is_not_0(self): |
| 77 | + def test_raises_BundlerExecutionError_with_stdout_text_if_retcode_is_not_0(self): |
77 | 78 | self.popen.returncode = 1
|
78 | 79 | self.popen.out = b"some error text\n\n"
|
| 80 | + self.popen.err = b"" |
79 | 81 | with self.assertRaises(BundlerExecutionError) as raised:
|
80 | 82 | self.under_test.run(["install", "--without", "development", "test"])
|
81 | 83 | self.assertEqual(raised.exception.args[0], "Bundler Failed: some error text")
|
82 | 84 |
|
| 85 | + def test_raises_BundlerExecutionError_with_stderr_text_if_retcode_is_not_0(self): |
| 86 | + self.popen.returncode = 1 |
| 87 | + self.popen.err = b"some error text\n\n" |
| 88 | + self.popen.out = b"" |
| 89 | + with self.assertRaises(BundlerExecutionError) as raised: |
| 90 | + self.under_test.run(["install", "--without", "development", "test"]) |
| 91 | + self.assertEqual(raised.exception.args[0], "Bundler Failed: some error text") |
| 92 | + |
| 93 | + def test_raises_BundlerExecutionError_with_both_stderr_and_stdout_text_if_retcode_is_not_0(self): |
| 94 | + self.popen.returncode = 1 |
| 95 | + self.popen.err = b"some error text from stderr\n\n" |
| 96 | + self.popen.out = b"some error text from stdout\n\n" |
| 97 | + with self.assertRaises(BundlerExecutionError) as raised: |
| 98 | + self.under_test.run(["install", "--without", "development", "test"]) |
| 99 | + self.assertEqual( |
| 100 | + raised.exception.args[0], f"Bundler Failed: some error text from stdout{linesep}some error text from stderr" |
| 101 | + ) |
| 102 | + |
83 | 103 | def test_raises_ValueError_if_args_not_a_list(self):
|
84 | 104 | with self.assertRaises(ValueError) as raised:
|
85 | 105 | self.under_test.run(("install", "--without", "development", "test"))
|
|
0 commit comments