Skip to content

Commit a9eee48

Browse files
committed
test: Fail list if a package is not a Git repository
1 parent 67b728e commit a9eee48

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

pkg/lib/commands/do-list.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ do-list() {
5757
printf -v pkg_output "%s\n" "$id"
5858

5959
if [ "$flag_simple" = 'no' ]; then
60-
ensure.git_repository "$pkg_path" "$id"
60+
if [ ! -d "$pkg_path/.git" ]; then
61+
die "Package '$id' is not a Git repository. Unlink or otherwise remove it at '$pkg_path'"
62+
fi
6163

6264
local repo_branch_str= repo_outdated_str=
6365

pkg/lib/util/ensure.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,3 @@ ensure.package_exists() {
3939
die "Package '$package' does not exist"
4040
fi
4141
}
42-
43-
ensure.git_repository() {
44-
local dir="$1"
45-
local id="$2"
46-
47-
if [ ! -d "$dir/.git" ]; then
48-
die "Package '$id' is not a Git repository. Unlink or otherwise remove it at '$dir'"
49-
fi
50-
}

tests/do-list.bats

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,14 @@ $site/username/p1
8686
Branch: master"
8787
}
8888

89-
@test "properly list outdated packages" {
89+
@test "error if tries to list a non-git repository with details" {
9090
local site="github.com"
91-
local pkg1='username/outdated'
92-
local pkg2='username/uptodate'
91+
local pkg='username/outdated'
9392

94-
test_util.create_package "$pkg1"
95-
test_util.create_package "$pkg2"
96-
test_util.fake_clone "$site/$pkg1"
97-
test_util.fake_clone "$site/$pkg2"
93+
mkdir -p "$BPM_PACKAGES_PATH/$site/$pkg"
9894

99-
# Make pkg1 outdated by commiting to it
100-
cd "$BPM_ORIGIN_DIR/$site/$pkg1"; {
101-
mkdir -p bin
102-
touch "bin/exec"
103-
git add .
104-
git commit -m "Add exec"
105-
}; cd "$BPM_CWD"
106-
107-
run do-list --outdated
95+
run do-list
10896

109-
assert_success
110-
assert_output 'github.com/username/outdated'
97+
assert_failure
98+
assert_line -n 0 -p "Package '$site/$pkg' is not a Git repository. Unlink or"
11199
}

0 commit comments

Comments
 (0)