Files
ar9av__obsidian-wiki/tests/test_sync_setup_parity.py
Arnav ea4508114e feat(sync): share one GitHub-sync implementation across setup.sh and the CLI (#153) (#154)
setup.sh had an interactive git-sync flow (git init, .gitignore, remote,
a generated sync.sh, optional cron) that `obsidian-wiki setup` — the entry
point pip/uv installs actually run — never had, so those installs silently
skipped it and .env.example documented a var nothing ever read.

Move the git plumbing into obsidian_wiki/sync.py (configure_sync/run_sync/
get_remote) and expose it as `obsidian-wiki sync-setup <url>` and
`obsidian-wiki sync`. `obsidian-wiki setup` now offers the same interactive
prompt setup.sh always had (or accepts --remote non-interactively), and
setup.sh's own prompt delegates into the same module via the CLI instead of
re-implementing it. Sync status is read live from the vault's own `git
remote` (via `obsidian-wiki info`) rather than a config var that could drift.
2026-07-25 21:52:11 -07:00

61 lines
2.3 KiB
Python

"""Regression guard for issue #153.
setup.sh (source/curl installs) used to hand-roll its own git-sync logic while
`obsidian-wiki setup` (the pip/uv CLI) had none at all — the two entrypoints
had diverged, and the one most users actually run (pip/uv) silently skipped
GitHub sync. Both now delegate to obsidian_wiki/sync.py. These tests pin that
setup.sh calls into the CLI instead of re-implementing git plumbing, and that
the CLI exposes the subcommands setup.sh (and agents, via wiki-setup) depend on.
"""
from __future__ import annotations
from pathlib import Path
import unittest
ROOT = Path(__file__).resolve().parents[1]
class SetupShDelegatesToCliTest(unittest.TestCase):
def setUp(self) -> None:
self.setup_sh = (ROOT / "setup.sh").read_text()
def test_calls_sync_setup_subcommand(self) -> None:
self.assertIn("sync-setup", self.setup_sh)
def test_calls_cli_module_not_a_standalone_git_flow(self) -> None:
self.assertIn("obsidian_wiki.cli", self.setup_sh)
def test_does_not_hand_roll_git_init(self) -> None:
# The old setup.sh ran `git -C "$VAULT_PATH" init` directly; that logic
# must now live only in obsidian_wiki/sync.py.
self.assertNotIn('git -C "$VAULT_PATH" init', self.setup_sh)
def test_does_not_generate_a_standalone_sync_script(self) -> None:
# The old setup.sh wrote a hand-rolled ~/.obsidian-wiki/sync.sh with its
# own git add/commit/push logic — that's now `obsidian-wiki sync`.
self.assertNotIn("Wrote ~/.obsidian-wiki/sync.sh", self.setup_sh)
class EnvExampleDoesNotOverclaimTest(unittest.TestCase):
def test_no_dangling_vault_github_remote_var(self) -> None:
env_example = (ROOT / ".env.example").read_text()
self.assertNotIn("VAULT_GITHUB_REMOTE", env_example)
class CliExposesSyncSubcommandsTest(unittest.TestCase):
def setUp(self) -> None:
self.cli = (ROOT / "obsidian_wiki" / "cli.py").read_text()
def test_sync_setup_subcommand_registered(self) -> None:
self.assertIn('sub.add_parser(\n "sync-setup"', self.cli)
def test_sync_subcommand_registered(self) -> None:
self.assertIn('sub.add_parser("sync"', self.cli)
def test_setup_command_offers_sync(self) -> None:
self.assertIn("_maybe_configure_sync", self.cli)
if __name__ == "__main__":
unittest.main()