From 2ba94a1f415b4e7e31d339f4c5985ff700ecaa54 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Tue, 2 Jun 2020 14:35:53 +0200 Subject: [PATCH] Add test_gen_env_command(). --- tests/test_jail.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_jail.py b/tests/test_jail.py index 2570f8a..6a4ef4f 100644 --- a/tests/test_jail.py +++ b/tests/test_jail.py @@ -1,5 +1,6 @@ from focker.jail import backup_file, \ - jail_fs_create + jail_fs_create, \ + gen_env_command import tempfile import os import subprocess @@ -65,3 +66,9 @@ def test_jail_fs_create_02(): subprocess.check_output(['focker', 'jail', 'remove', 'test-jail-fs-create-02']) assert not zfs_exists(name) assert not os.path.exists(mountpoint) + + +def test_gen_env_command(): + command = gen_env_command('echo $TEST_VARIABLE_1 && echo $TEST_VARIABLE_2', + {'TEST_VARIABLE_1': 'foo', 'TEST_VARIABLE_2': 'foo bar'}) + assert command == 'export TEST_VARIABLE_1=foo && export TEST_VARIABLE_2=\'foo bar\' && echo $TEST_VARIABLE_1 && echo $TEST_VARIABLE_2'