From 136626958696847762d485ffda6fa65495e58742 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 30 Nov 2024 09:44:55 -0800 Subject: [PATCH] Add a couple of missing tests (#251). --- borgmatic/config/schema.yaml | 2 ++ borgmatic/hooks/data_source/btrfs.py | 1 - tests/unit/config/test_paths.py | 16 ++++++++++++++++ tests/unit/hooks/data_source/test_btrfs.py | 1 - 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index 9ba69a13..c2e900ef 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -2302,3 +2302,5 @@ properties: description: | Command to use instead of "findmnt". example: /usr/local/bin/findmnt + description: | + Configuration for integration with the Btrfs filesystem. diff --git a/borgmatic/hooks/data_source/btrfs.py b/borgmatic/hooks/data_source/btrfs.py index 8c78620c..4ea270fa 100644 --- a/borgmatic/hooks/data_source/btrfs.py +++ b/borgmatic/hooks/data_source/btrfs.py @@ -1,4 +1,3 @@ -import functools import glob import logging import os diff --git a/tests/unit/config/test_paths.py b/tests/unit/config/test_paths.py index 294212ba..a63c86e1 100644 --- a/tests/unit/config/test_paths.py +++ b/tests/unit/config/test_paths.py @@ -45,6 +45,22 @@ def test_replace_temporary_subdirectory_with_glob_transforms_path(): ) +def test_replace_temporary_subdirectory_with_glob_passes_through_non_matching_path(): + assert ( + module.replace_temporary_subdirectory_with_glob('/tmp/foo-aet8kn93/borgmatic') + == '/tmp/foo-aet8kn93/borgmatic' + ) + + +def test_replace_temporary_subdirectory_with_glob_uses_custom_temporary_directory_prefix(): + assert ( + module.replace_temporary_subdirectory_with_glob( + '/tmp/.borgmatic-aet8kn93/borgmatic', temporary_directory_prefix='.borgmatic-' + ) + == '/tmp/.borgmatic-*/borgmatic' + ) + + def test_runtime_directory_uses_config_option(): flexmock(module).should_receive('expand_user_in_path').replace_with(lambda path: path) flexmock(module.os).should_receive('makedirs') diff --git a/tests/unit/hooks/data_source/test_btrfs.py b/tests/unit/hooks/data_source/test_btrfs.py index d9bc2b42..6e4fbf7d 100644 --- a/tests/unit/hooks/data_source/test_btrfs.py +++ b/tests/unit/hooks/data_source/test_btrfs.py @@ -1,4 +1,3 @@ -import pytest from flexmock import flexmock from borgmatic.hooks.data_source import btrfs as module