From b8dfbae730ca723006ee8a0b7b8549e232e6fefa Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 26 Apr 2022 21:02:40 -0500 Subject: [PATCH] Migrate config-* tests to Python --- tests/test_config.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/test_config.py diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..d6338d4 --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,36 @@ +import json +import os + + +def test_config_blank(dotfiles, run_dotbot): + """Verify blank configs work.""" + + dotfiles.write_config([]) + run_dotbot() + + +def test_config_empty(dotfiles, run_dotbot): + """Verify empty configs work.""" + + dotfiles.write("config.yaml", "") + run_dotbot("-c", os.path.join(dotfiles.directory, "config.yaml"), custom=True) + + +def test_json(home, dotfiles, run_dotbot): + """Verify JSON configs work.""" + + document = json.dumps([{"create": ["~/d"]}]) + dotfiles.write("config.json", document) + run_dotbot("-c", os.path.join(dotfiles.directory, "config.json"), custom=True) + + assert os.path.isdir(os.path.join(home, "d")) + + +def test_json_tabs(home, dotfiles, run_dotbot): + """Verify JSON configs with tabs work.""" + + document = """[\n\t{\n\t\t"create": ["~/d"]\n\t}\n]""" + dotfiles.write("config.json", document) + run_dotbot("-c", os.path.join(dotfiles.directory, "config.json"), custom=True) + + assert os.path.isdir(os.path.join(home, "d"))