Skip to content

Commit

Permalink
Check signed into Mac App Store before running mas
Browse files Browse the repository at this point in the history
  • Loading branch information
skylarmacdonald committed Feb 27, 2021
1 parent f6f20f0 commit ee3e3cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/type-mas.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mas () { . $BORK_SOURCE_DIR/types/mas.sh $*; }

setup () {
respond_to "uname -s" "echo Darwin"
respond_to "mas account" "echo 'user@example.com'"
respond_to "mas list" "cat $fixtures/mas-list.txt"
respond_to "mas outdated" "cat $fixtures/mas-outdated.txt"
}
Expand All @@ -15,6 +16,12 @@ setup () {
[ "$status" -eq $STATUS_FAILED_PRECONDITION ]
}

@test "mas status: returns FAILED_PRECONDITION when logged out" {
respond_to "mas account" "return 1"
run mas status 497799835 Xcode
[ "$status" -eq $STATUS_FAILED_PRECONDITION ]
}

@test "mas status: returns MISSING when app not installed" {
run mas status 477670270 2Do
[ "$status" -eq $STATUS_MISSING ]
Expand Down
2 changes: 2 additions & 0 deletions types/mas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ case $action in
status)
baking_platform_is "Darwin" || return $STATUS_UNSUPPORTED_PLATFORM
needs_exec "mas" || return $STATUS_FAILED_PRECONDITION
bake mas account
[ "$?" -gt 0 ] && return $STATUS_FAILED_PRECONDITION
bake mas list | grep -E "^$appid" > /dev/null
[ "$?" -gt 0 ] && return $STATUS_MISSING
bake mas outdated | grep -E "^$appid" > /dev/null
Expand Down

0 comments on commit ee3e3cb

Please sign in to comment.