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:

  1. Basic git repository detection
  2. Non-git directory handling
  3. Modified files detection
  4. Staged files detection
  5. Untracked files detection
  6. Multiple file states
  7. 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, and src/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:

  1. First cd into repo: auth check runs asynchronously in background
  2. Background check tests SSH connection with ssh -o BatchMode=yes
  3. Result cached in ~/.cache/slick/auth_* for 5 minutes
  4. 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

ScenarioTest #What It Verifies
SSH unreachable12Timeout works (no hang)
SSH auth required13No password prompt, no hang
HTTPS remote11Quick completion
No remote1-10Normal git operations
Fetch disabled16Skips network entirely

CI/CD

just check

Runs:

  • โœ… Cargo clippy (strict)
  • โœ… Cargo tests (98 tests)
  • โœ… Release build
  • โœ… Integration tests (19 tests)

Performance Expectations

TestExpected 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