diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2022-03-22 14:25:24 -0400 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2022-03-25 10:30:31 -0400 |
commit | 3b0676b90ff65f20eaba3062775ff72b89386ffc (patch) | |
tree | 5f1615ada6823c303f470715140bfefb7070b121 /tests/unittests/plugin_tests.py | |
parent | 2666cb75fd8a463a8366dfb1d969b17ab5a95152 (diff) | |
download | sos-3b0676b90ff65f20eaba3062775ff72b89386ffc.tar.gz |
[Plugin] Allow plugins to define default command environment vars
Adds the ability for plugins to define a default set of environment vars
to pass to all commands executed by the plugin. This may be done either
via the new `set_default_cmd_environment()` or
`add_default_cmd_environment()` methods. The former will override any
previously set values, whereas the latter will add/update/modify any
existing values.
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/unittests/plugin_tests.py')
-rw-r--r-- | tests/unittests/plugin_tests.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unittests/plugin_tests.py b/tests/unittests/plugin_tests.py index 0dfa243d..e469b78e 100644 --- a/tests/unittests/plugin_tests.py +++ b/tests/unittests/plugin_tests.py @@ -305,6 +305,21 @@ class PluginTests(unittest.TestCase): p.postproc() self.assertTrue(p.did_postproc) + def test_set_default_cmd_env(self): + p = MockPlugin({ + 'sysroot': self.sysroot, + 'policy': LinuxPolicy(init=InitSystem(), probe_runtime=False), + 'cmdlineopts': MockOptions(), + 'devices': {} + }) + e = {'TORVALDS': 'Linus'} + p.set_default_cmd_environment(e) + self.assertEquals(p.default_environment, e) + add_e = {'GREATESTSPORT': 'hockey'} + p.add_default_cmd_environment(add_e) + self.assertEquals(p.default_environment['GREATESTSPORT'], 'hockey') + self.assertEquals(p.default_environment['TORVALDS'], 'Linus') + class AddCopySpecTests(unittest.TestCase): |