2022-04-26 22:02:40 -04:00
|
|
|
import json
|
|
|
|
import os
|
2024-12-28 01:01:05 -05:00
|
|
|
from typing import Callable
|
2022-04-26 22:02:40 -04:00
|
|
|
|
2024-12-28 01:01:05 -05:00
|
|
|
from tests.conftest import Dotfiles
|
2022-04-26 22:02:40 -04:00
|
|
|
|
2024-12-28 01:01:05 -05:00
|
|
|
|
|
|
|
def test_config_blank(dotfiles: Dotfiles, run_dotbot: Callable[..., None]) -> None:
|
2022-04-26 22:02:40 -04:00
|
|
|
"""Verify blank configs work."""
|
|
|
|
|
|
|
|
dotfiles.write_config([])
|
|
|
|
run_dotbot()
|
|
|
|
|
|
|
|
|
2024-12-28 01:01:05 -05:00
|
|
|
def test_config_empty(dotfiles: Dotfiles, run_dotbot: Callable[..., None]) -> None:
|
2022-04-26 22:02:40 -04:00
|
|
|
"""Verify empty configs work."""
|
|
|
|
|
|
|
|
dotfiles.write("config.yaml", "")
|
|
|
|
run_dotbot("-c", os.path.join(dotfiles.directory, "config.yaml"), custom=True)
|
|
|
|
|
|
|
|
|
2024-12-28 01:01:05 -05:00
|
|
|
def test_json(home: str, dotfiles: Dotfiles, run_dotbot: Callable[..., None]) -> None:
|
2022-04-26 22:02:40 -04:00
|
|
|
"""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"))
|
|
|
|
|
|
|
|
|
2024-12-28 01:01:05 -05:00
|
|
|
def test_json_tabs(home: str, dotfiles: Dotfiles, run_dotbot: Callable[..., None]) -> None:
|
2022-04-26 22:02:40 -04:00
|
|
|
"""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"))
|