aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-14 08:07:21 -0500
committerCraig Jennings <c@cjennings.net>2026-05-14 08:07:21 -0500
commit1e21c2c31a44d3a2a9e302de4712b482de597058 (patch)
tree452bf4098b4c58a7fc948aaa020ee0b51bc76287 /tests
parentaf12ac6a7375f1651cb207d3e1bcd194a97a77a9 (diff)
downloaddotemacs-1e21c2c31a44d3a2a9e302de4712b482de597058.tar.gz
dotemacs-1e21c2c31a44d3a2a9e302de4712b482de597058.zip
feat(setup-telega): install the telega Emacs package alongside docker setup
modules/telega-config.el uses `:ensure nil' on the use-package block (a stale MELPA archive index can 404 and take startup down if auto-install runs in init). The trade-off was that a fresh clone needed a one-time `M-x package-install RET telega' before the dashboard launcher or `C-; G' would work -- the autoload stub would fail with `Cannot open load file: telega' instead. Hit it on this machine just now: dashboard pressed, autoload tried to load telega.el, no telega.el on the load-path, cryptic error. Add `ensure_telega_package' to the setup script: probe with `(package-installed-p 'telega)' under `emacs --batch'; if absent, refresh MELPA and install via package.el; if that fails, surface the manual recovery path. Wire it into `main' after the docker checks. Four new bats tests cover the missing-emacs, already- installed, install-succeeds, and install-fails paths with `emacs' stubbed at the function level.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-setup-telega.bats47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test-setup-telega.bats b/tests/test-setup-telega.bats
index 7935ea4a..3282b9e1 100644
--- a/tests/test-setup-telega.bats
+++ b/tests/test-setup-telega.bats
@@ -85,3 +85,50 @@ setup() {
[ "$status" -eq 1 ]
[[ "$output" == *"pull failed"* ]]
}
+
+# --------------------------- ensure_telega_package ------------------------
+
+@test "ensure_telega_package: fails when emacs is missing" {
+ command() {
+ if [[ "$1" == "-v" && "$2" == "emacs" ]]; then
+ return 1
+ fi
+ builtin command "$@"
+ }
+ run ensure_telega_package
+ [ "$status" -eq 1 ]
+ [[ "$output" == *"emacs not on PATH"* ]]
+}
+
+@test "ensure_telega_package: skips when telega already installed" {
+ # Stub emacs so the first --batch probe (package-installed-p) exits 0.
+ emacs() { return 0; }
+ export -f emacs
+ run ensure_telega_package
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"already installed"* ]]
+}
+
+@test "ensure_telega_package: installs when telega not yet present" {
+ # First call (probe) returns 1 "not installed"; second call (install) returns 0.
+ emacs() {
+ if [[ "$*" == *"package-installed-p"* ]]; then
+ return 1
+ fi
+ return 0
+ }
+ export -f emacs
+ run ensure_telega_package
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"telega installed"* ]]
+}
+
+@test "ensure_telega_package: reports failure when install fails" {
+ # Both calls return non-zero so the install path errors.
+ emacs() { return 1; }
+ export -f emacs
+ run ensure_telega_package
+ [ "$status" -eq 1 ]
+ [[ "$output" == *"install failed"* ]]
+ [[ "$output" == *"M-x package-install"* ]]
+}