2
0
Эх сурвалжийг харах

Additional test coverage (#966).

Dan Helfman 10 сар өмнө
parent
commit
24b846e9ca

+ 15 - 0
tests/unit/borg/test_environment.py

@@ -33,6 +33,21 @@ def test_make_environment_with_passphrase_should_set_environment():
     assert environment.get('BORG_PASSPHRASE') == 'pass'
 
 
+def test_make_environment_with_credential_tag_passphrase_should_load_it_and_set_environment():
+    flexmock(module.borgmatic.borg.passcommand).should_receive(
+        'get_passphrase_from_passcommand'
+    ).and_return(None)
+    flexmock(module.os).should_receive('pipe').never()
+    flexmock(module.os.environ).should_receive('get').and_return(None)
+    flexmock(module.borgmatic.hooks.credential.tag).should_receive('resolve_credential').with_args(
+        '!credential systemd pass'
+    ).and_return('pass')
+
+    environment = module.make_environment({'encryption_passphrase': '!credential systemd pass'})
+
+    assert environment.get('BORG_PASSPHRASE') == 'pass'
+
+
 def test_make_environment_with_ssh_command_should_set_environment():
     flexmock(module.borgmatic.borg.passcommand).should_receive(
         'get_passphrase_from_passcommand'