Skip to content

Commit 02fefcd

Browse files
add tests for android sdk
1 parent 9bd68db commit 02fefcd

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/zsh/plugin-init/android-sdk.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ else
2727
echo " sdkmanager --install \"cmdline-tools;latest\""
2828
echo "Once installed, ensure the cmdline-tools are located at: $ANDROID_HOME/cmdline-tools/latest/bin"
2929
fi
30-
fi
30+
fi

tests/test_plugin_android_sdk.bats

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bats
2+
# tests/test_plugin_android_sdk.bats - Verify android-sdk plugin init behavior
3+
4+
load helpers
5+
6+
setup() {
7+
export TEST_TEMP_DIR=$(mktemp -d)
8+
export HOME="$TEST_TEMP_DIR/home"
9+
mkdir -p "$HOME"
10+
# Ensure OSA_REPO_PATH is available to helpers
11+
export OSA_REPO_PATH="$OSA_TEST_REPO_ROOT"
12+
}
13+
14+
teardown() {
15+
rm -rf "$TEST_TEMP_DIR"
16+
}
17+
18+
@test "android-sdk plugin informs user when Android SDK cmdline-tools missing" {
19+
run bash -c ". '$OSA_TEST_REPO_ROOT/src/zsh/plugin-init/android-sdk.zsh'"
20+
# The plugin should not error; it should print an informative message about missing cmdline-tools
21+
[[ "$status" -eq 0 ]]
22+
[[ "$output" =~ "Android cmdline-tools not found" ]] || [[ "$output" =~ "Available cmdline-tools directories" ]]
23+
}
24+
25+
@test "android-sdk plugin suggests symlink when cmdline-tools present but 'latest' missing" {
26+
# Create a fake cmdline-tools/version directory but not 'latest'
27+
mkdir -p "$HOME/Library/Android/sdk/cmdline-tools/5.0"
28+
29+
run bash -c ". '$OSA_TEST_REPO_ROOT/src/zsh/plugin-init/android-sdk.zsh'"
30+
[[ "$status" -eq 0 ]]
31+
# Should list available cmdline-tools directories and suggest creating a 'latest' symlink
32+
[[ "$output" =~ "Available cmdline-tools directories" ]]
33+
[[ "$output" =~ "create a 'latest' symlink" ]] || [[ "$output" =~ "ln -s" ]]
34+
}

0 commit comments

Comments
 (0)