Compare commits

..

3 Commits

Author SHA1 Message Date
renovate[bot]
d54433cbf9 chore(deps): update image python to v3.14.3
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-07 21:28:13 +00:00
765c2fce72 test(dfm): expand bats tests from 1 to 16
Add tests for menu output of all sections (install, helpers, docs,
dotfiles, check, scripts, tests), routing of invalid input, install
menu completeness for all 19 entries, and check arch/host commands.
2026-02-07 23:20:02 +02:00
88eceaf194 fix(dfm): restrict cheat-databases glob to .sh files only
The install-cheat-* glob was matching .md documentation files, causing
errors when bash tried to execute them.
2026-02-07 22:45:08 +02:00
3 changed files with 135 additions and 2 deletions

View File

@@ -1 +1 @@
3.14.2
3.14.3

View File

@@ -112,7 +112,7 @@ section_install()
cheat-databases)
msgr run "Installing cheat databases..."
for database in "$DOTFILES"/scripts/install-cheat-*; do
for database in "$DOTFILES"/scripts/install-cheat-*.sh; do
bash "$database" \
&& msgr run_done "Cheat: $database run"
done

View File

@@ -5,8 +5,141 @@ setup()
export DOTFILES="$PWD"
}
# ── Group 1: Main help & routing ──────────────────────────────
@test "dfm help shows usage" {
run bash local/bin/dfm help
[ "$status" -eq 0 ]
[[ "$output" == *"Usage: dfm"* ]]
}
@test "dfm with no args shows full usage with all sections" {
run bash local/bin/dfm
[ "$status" -eq 0 ]
[[ "$output" == *"Usage: dfm"* ]]
[[ "$output" == *"dfm install"* ]]
[[ "$output" == *"dfm check"* ]]
[[ "$output" == *"dfm helpers"* ]]
[[ "$output" == *"dfm docs"* ]]
[[ "$output" == *"dfm dotfiles"* ]]
[[ "$output" == *"dfm scripts"* ]]
}
@test "dfm with invalid section shows usage" {
run bash local/bin/dfm nonexistent
[ "$status" -eq 0 ]
[[ "$output" == *"Usage: dfm"* ]]
}
# ── Group 2: Install menu completeness ────────────────────────
@test "dfm install menu shows all entries" {
run bash local/bin/dfm install
[ "$status" -eq 0 ]
[[ "$output" == *"all"* ]]
[[ "$output" == *"apt-packages"* ]]
[[ "$output" == *"cargo"* ]]
[[ "$output" == *"cheat-databases"* ]]
[[ "$output" == *"composer"* ]]
[[ "$output" == *"dnf-packages"* ]]
[[ "$output" == *"fonts"* ]]
[[ "$output" == *"gh"* ]]
[[ "$output" == *"git-crypt"* ]]
[[ "$output" == *"go"* ]]
[[ "$output" == *"imagick"* ]]
[[ "$output" == *"macos"* ]]
[[ "$output" == *"npm-packages"* ]]
[[ "$output" == *"ntfy"* ]]
[[ "$output" == *"nvm-latest"* ]]
[[ "$output" == *"nvm"* ]]
[[ "$output" == *"python-packages"* ]]
[[ "$output" == *"xcode-cli-tools"* ]]
[[ "$output" == *"z"* ]]
}
@test "dfm install with invalid subcommand shows menu" {
run bash local/bin/dfm install nonexistent
[ "$status" -eq 0 ]
[[ "$output" == *"dfm install"* ]]
}
# ── Group 3: Other section menus ──────────────────────────────
@test "dfm helpers menu shows entries" {
run bash local/bin/dfm helpers
[ "$status" -eq 0 ]
[[ "$output" == *"aliases"* ]]
[[ "$output" == *"colors"* ]]
[[ "$output" == *"path"* ]]
[[ "$output" == *"env"* ]]
}
@test "dfm docs menu shows entries" {
run bash local/bin/dfm docs
[ "$status" -eq 0 ]
[[ "$output" == *"all"* ]]
[[ "$output" == *"tmux"* ]]
[[ "$output" == *"nvim"* ]]
[[ "$output" == *"wezterm"* ]]
}
@test "dfm dotfiles menu shows entries" {
run bash local/bin/dfm dotfiles
[ "$status" -eq 0 ]
[[ "$output" == *"fmt"* ]]
[[ "$output" == *"shfmt"* ]]
[[ "$output" == *"yamlfmt"* ]]
}
@test "dfm check menu shows entries" {
run bash local/bin/dfm check
[ "$status" -eq 0 ]
[[ "$output" == *"arch"* ]]
[[ "$output" == *"host"* ]]
}
@test "dfm scripts menu lists install scripts" {
run bash local/bin/dfm scripts
[ "$status" -eq 0 ]
[[ "$output" == *"cargo-packages"* ]]
[[ "$output" == *"fonts"* ]]
[[ "$output" == *"z"* ]]
}
@test "dfm tests menu shows entries" {
run bash local/bin/dfm tests
[ "$status" -eq 0 ]
[[ "$output" == *"msgr"* ]]
[[ "$output" == *"params"* ]]
}
# ── Group 4: Check commands ───────────────────────────────────
@test "dfm check arch returns current arch" {
run bash local/bin/dfm check arch
[ "$status" -eq 0 ]
[ -n "$output" ]
}
@test "dfm check arch with matching value exits 0" {
local current_arch
current_arch="$(uname)"
run bash local/bin/dfm check arch "$current_arch"
[ "$status" -eq 0 ]
}
@test "dfm check arch with non-matching value exits 1" {
run bash local/bin/dfm check arch FakeArch
[ "$status" -eq 1 ]
}
@test "dfm check host returns current hostname" {
run bash local/bin/dfm check host
[ "$status" -eq 0 ]
[ -n "$output" ]
}
@test "dfm check host with non-matching value exits 1" {
run bash local/bin/dfm check host fakehostname
[ "$status" -eq 1 ]
}