|
12 | 12 | AutoUpdateResult, |
13 | 13 | AutoUpdateStatus, |
14 | 14 | InstallSource, |
| 15 | + _check_homebrew_update_available, |
15 | 16 | _is_interactive_session, |
16 | 17 | detect_install_source, |
17 | 18 | maybe_run_periodic_auto_update, |
@@ -129,6 +130,30 @@ def test_force_bypasses_auto_update_disabled(monkeypatch, tmp_path): |
129 | 130 | assert manager.save_calls == 1 |
130 | 131 |
|
131 | 132 |
|
| 133 | +def test_check_homebrew_update_available_exit_code_1_means_outdated(monkeypatch): |
| 134 | + """brew outdated exits 1 when the formula is outdated, not on error.""" |
| 135 | + |
| 136 | + def _fake_run(command, **kwargs): |
| 137 | + return subprocess.CompletedProcess( |
| 138 | + command, 1, stdout="basicmachines-co/basic-memory/basic-memory\n", stderr="" |
| 139 | + ) |
| 140 | + |
| 141 | + monkeypatch.setattr("basic_memory.cli.auto_update._run_subprocess", _fake_run) |
| 142 | + is_outdated, _ = _check_homebrew_update_available(silent=False) |
| 143 | + assert is_outdated is True |
| 144 | + |
| 145 | + |
| 146 | +def test_check_homebrew_update_available_exit_code_0_means_up_to_date(monkeypatch): |
| 147 | + """brew outdated exits 0 when the formula is up to date.""" |
| 148 | + |
| 149 | + def _fake_run(command, **kwargs): |
| 150 | + return subprocess.CompletedProcess(command, 0, stdout="", stderr="") |
| 151 | + |
| 152 | + monkeypatch.setattr("basic_memory.cli.auto_update._run_subprocess", _fake_run) |
| 153 | + is_outdated, _ = _check_homebrew_update_available(silent=False) |
| 154 | + assert is_outdated is False |
| 155 | + |
| 156 | + |
132 | 157 | def test_homebrew_outdated_triggers_upgrade(monkeypatch, tmp_path): |
133 | 158 | config = _base_config(tmp_path) |
134 | 159 | manager = StubConfigManager(config) |
|
0 commit comments