浏览代码

Additional test coverage (#966).

Dan Helfman 5 月之前
父节点
当前提交
24b846e9ca
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      tests/unit/borg/test_environment.py

+ 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'
     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():
 def test_make_environment_with_ssh_command_should_set_environment():
     flexmock(module.borgmatic.borg.passcommand).should_receive(
     flexmock(module.borgmatic.borg.passcommand).should_receive(
         'get_passphrase_from_passcommand'
         'get_passphrase_from_passcommand'