Testing Slick Prompt
April 4, 2026 ยท View on GitHub
Quick Start
# Run all tests
just test
# Or run directly
./test.sh
Test Coverage
Integration Tests (19 tests)
Basic Functionality:
- Basic git repository detection
- Non-git directory handling
- Modified files detection
- Staged files detection
- Untracked files detection
- Multiple file states
- JSON output format validation
Edge Cases: 8. Detached HEAD state 9. Prompt display integration 10. Empty repository handling
Performance: 11. Performance (fetch disabled) 16. Fetch disabled with unreachable remote 17. Performance benchmark (10 iterations)
Network & Auth Protection: โก 11. HTTPS remote handling 12. SSH remote timeout (unreachable IP) 13. SSH auth prompt protection (prevents password/key prompts) ๐ 14. Git user name detection
Cargo Test Suite (98 tests)
cargo test
- 35 prompt/lib/context tests (
src/lib.rs,src/context.rs, andsrc/prompt.rs) - 12 auth cache tests
- 9 environment tests
- 8 git integration tests
- 5 git unit tests
- 6 elapsed-time prompt tests
- 23 prompt rendering tests
Total: 117 checks (98 cargo tests + 19 integration tests)
Auth/Credential Protection
Test #13 verifies that slick never prompts for credentials:
# What it tests:
git remote add origin git@github.com:fake-org/private-repo.git
slick precmd # Should NOT prompt for password/SSH key
# Protection mechanisms tested:
- GIT_TERMINAL_PROMPT=0
- GIT_ASKPASS=echo
- SSH_ASKPASS=echo
- SSH BatchMode=yes
- Timeout protection
Result: โ No hanging, no password prompts, completes quickly
Justfile Commands
just test # Clippy + cargo tests + integration tests
just check # All tests + format check
just clippy # Run clippy with strict warnings
just build # Build release binary
just fmt # Format code
just clean # Clean build artifacts
just integration # Run integration tests only
just preview # Render Toolbx/DevPod/AWS/Kubernetes/Python prompt contexts
just preview-watch # Refresh the prompt preview continuously
just version # Show version
Manual Testing
Test Auth Lock Detection
The auth lock symbol (๐) appears when SSH authentication is required:
# Create repo with SSH remote that requires auth
mkdir /tmp/test-auth-lock && cd /tmp/test-auth-lock
git init
git config user.email "test@test.com"
git config user.name "Test User"
echo "test" > file.txt
git add . && git commit -m "init"
git checkout -b main
# Add private repo remote (one that requires SSH key)
git remote add origin git@github.com:private-org/private-repo.git
git config branch.main.remote origin
git config branch.main.merge refs/heads/main
# First time: no lock (auth check runs in background)
slick precmd
# Output: {"auth_failed":false,...}
# Wait a few seconds for background check
sleep 4
# Second time: lock appears! ๐
slick precmd
# Output: {"auth_failed":true,...}
# View full prompt with lock symbol
DATA=$(slick precmd)
slick prompt -d "$DATA" -r 0
# Shows: ... main ๐ ...
How it works:
- First
cdinto repo: auth check runs asynchronously in background - Background check tests SSH connection with
ssh -o BatchMode=yes - Result cached in
~/.cache/slick/auth_*for 5 minutes - Next prompt: reads cache and displays lock if auth is required
Cache location:
ls -la ~/.cache/slick/
cat ~/.cache/slick/auth_* # timestamp:status (1=auth required)
Test Timeout Protection
# Add unreachable remote
git remote add origin git@192.0.2.1:fake/repo.git
# Should complete in < 6 seconds
time slick precmd
What Gets Tested
| Scenario | Test # | What It Verifies |
|---|---|---|
| SSH unreachable | 12 | Timeout works (no hang) |
| SSH auth required | 13 | No password prompt, no hang |
| HTTPS remote | 11 | Quick completion |
| No remote | 1-10 | Normal git operations |
| Fetch disabled | 16 | Skips network entirely |
CI/CD
just check
Runs:
- โ Cargo clippy (strict)
- โ Cargo tests (98 tests)
- โ Release build
- โ Integration tests (19 tests)
Performance Expectations
| Test | Expected Time |
|---|---|
| Local operations (fetch disabled) | < 100ms |
| HTTPS remote | < 3s |
| SSH unreachable | < 6s |
| SSH auth required | < 8s |
| Benchmark average | < 100ms |
Summary
Simple workflow:
just test # Everything
Total coverage: 118 checks
- 98 Cargo tests โ
- 20 Integration tests โ
- Including SSH auth prompt protection ๐
- Including SSH timeout protection โก
- Including slick.zsh preexec/transient regression guard ๐ก๏ธ
- Including load.zsh and slick.plugin.zsh wrapper guards ๐
- All passing โ
Key Features Tested:
- โ No password prompts
- โ No SSH key prompts
- โ Timeout protection
- โ Fast execution
- โ Complete git status detection