8.0 KiB
Verification Steps for sync-git-project.sh
This document outlines testing steps and edge cases for verifying the enhanced sync-git-project.sh script.
Prerequisites
Before testing, ensure you have:
- A test server with SSH access
- A git repository on the server
sshpassinstalled locally- Docker installed and running
makeavailable
Test Cases
1. Clone Test
Purpose: Verify git clone works with credentials
Steps:
- Run
./sync-project.sh --git - Provide valid server credentials
- Verify repository is cloned to LOCAL_FOLDER
Expected: Repository cloned successfully, cd into project works
Edge cases:
- Wrong SSH credentials → Should show error and exit
- Repository doesn't exist → Should show clear error message
- LOCAL_FOLDER already exists → Git will fail with appropriate error
2. .npmrc Check
Purpose: Test with/without .npmrc file
Steps:
- Clone a project without .npmrc
- Verify script pauses and prompts user
- Add .npmrc file
- Press Enter to continue
Expected: Script pauses with clear message, continues after file added
3. Docker Env Copy
Purpose: Verify .docker/config/.env.local exists and copies correctly
Steps:
- Ensure .docker/config/.env.local exists in repo
- Run setup
- Verify .env created in project root
Expected: .env copied from .docker/config/.env.local
Edge cases:
- .docker/config/.env.local missing → Pause and prompt user
4. Clean Docker Volumes
Purpose: Verify Docker volumes are cleaned before setup
Steps:
- Have existing Docker containers and volumes running
- Run setup
- Verify all containers stopped and removed
- Verify all volumes removed
Expected:
docker ps -ashows no containersdocker volume lsshows no volumes
Edge cases:
- No containers running → Commands succeed silently
- No volumes exist → Commands succeed silently
5. Docker Setup
Purpose: Test with/without docker-setup.sh present
Steps:
- Test with project containing docker-setup.sh
- Test with project missing docker-setup.sh
Expected:
- With script: Runs
sh docker-setup.sh - Without script: Pauses and notifies user
6. Server .env Copy
Purpose: Verify scp copies .env to .server.env
Steps:
- Ensure .env exists on server
- Run setup
- Verify .server.env created locally
- Run
git ls-files -v | grep .server.envto verify assume-unchanged
Expected: .server.env copied and marked with 'h' (assume-unchanged)
Edge cases:
- Server .env missing → Pause and prompt user
7. .env Modification
Purpose: Check APP_NAME/APP_KEY extraction and insertion
Steps:
- Verify .server.env contains APP_NAME and APP_KEY
- Run setup
- Check local .env for updated values
Expected: APP_NAME and APP_KEY from .server.env appear in local .env
Edge cases:
- APP_NAME missing in .server.env → Yellow warning, continues
- APP_KEY missing in .server.env → Yellow warning, continues
8. .env.prod.local Creation
Purpose: Verify all 5 variables populated correctly
Steps:
- Run setup with valid server credentials
- Check .env.prod.local contents
Expected file contents:
PROD_HOST="<extracted from SERVER_HOST>"
PROD_USER="<extracted from SERVER_HOST>"
PROD_DB_NAME="<DB_DATABASE from .server.env>"
PROD_DB_USER="<DB_USERNAME from .server.env>"
PROD_DB_PASS="<DB_PASSWORD from .server.env>"
9. Helper Scripts
Purpose: Verify ssh.sh created correctly
Steps:
- Run setup
- Check ssh.sh exists with executable permission
- Verify ssh.sh contains correct variables
- Check .gitignore includes ssh.sh
Expected: ssh.sh created with embedded credentials, added to .gitignore
10. Lazygit Upload
Purpose: Verify upload and assume-unchanged on both server and local
Steps:
- Run setup
- SSH to server, check lazygit exists in project
- On server:
git ls-files -v | grep lazygitshows 'h' - Locally:
git ls-files -v | grep lazygitshows 'h'
Expected: lazygit uploaded and marked assume-unchanged on both ends
11. SSH Keys - Case A
Purpose: Server with only public key
Setup:
# On server
rm ~/.ssh/id_rsa
# Keep ~/.ssh/id_rsa.pub
Steps:
- Run setup
- Verify staging.key created locally
- Verify both keys uploaded to server
- Verify public key added to authorized_keys
Expected: New keypair generated, uploaded, authorized
12. SSH Keys - Case B
Purpose: Server with both keys
Setup:
# Server has both ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub
Steps:
- Run setup
- Verify staging.key downloaded (matches server's id_rsa)
- Verify public key in authorized_keys
Expected: Private key downloaded as staging.key
13. SSH Keys - Case C
Purpose: Server with neither key
Setup:
# On server
rm -rf ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
# or rm -rf ~/.ssh
Steps:
- Run setup
- Verify ~/.ssh created on server
- Verify both keys uploaded
- Verify authorized_keys created/updated
Expected: New keypair generated, ~/.ssh created, keys uploaded
14. staging.key Assume-Unchanged
Purpose: Verify git tracking status
Steps:
- After setup, run:
git ls-files -v | grep staging.key
Expected: Output shows 'h staging.key' (lowercase h = assume-unchanged)
15. SSH-Add
Purpose: Verify key added to agent
Steps:
- Ensure ssh-agent is running:
eval $(ssh-agent -s) - Run setup
- Check:
ssh-add -lshould show staging.key
Expected: staging.key fingerprint shown in ssh-add -l
Edge cases:
- ssh-agent not running → Pause with instructions
16. db:wipe
Purpose: Verify database wipe works
Steps:
- Ensure mtc-pharmacy-web container is running
- Run setup
- Verify db:wipe command executes
Expected: Database wiped successfully
Edge cases:
- Container not running → Pause with instructions
17. db-sync
Purpose: Verify make db-sync runs
Steps:
- Ensure Makefile exists with db-sync target
- Ensure .env.prod.local has correct values
- Run setup
Expected: Database synced from staging
Edge cases:
- Makefile missing → Error from make
- db-sync target missing → Error from make
- Connection fails → Pause with instructions
Edge Cases Summary
| Scenario | Expected Behavior |
|---|---|
| Clone fails (wrong credentials) | Red error, exit |
| Clone fails (repo doesn't exist) | Red error, exit |
| .npmrc missing | Yellow pause, wait for user |
| .docker/config/.env.local missing | Red error, pause, retry |
| No Docker containers/volumes | Commands succeed silently |
| docker-setup.sh missing | Yellow pause, notify user |
| Server .env missing | Red error, pause, retry |
| .server.env malformed | get_env_value returns empty, yellow warning |
| ~/.ssh doesn't exist on server | Create directory (Case C) |
| authorized_keys doesn't exist | Create with public key |
| staging.key assume-unchanged fails | Suppress error, continue |
| ssh-agent not running | Yellow warning, instructions, pause |
| Docker container not running | Yellow warning, pause, retry |
| make db-sync fails | Yellow warning, pause |
Manual Verification Checklist
- Clone test passes
- .npmrc check pauses correctly
- Docker env copied
- Docker volumes cleaned
- docker-setup.sh runs or notifies
- Server .env copied to .server.env
- .server.env marked assume-unchanged
- APP_NAME/APP_KEY extracted and set
- .env.prod.local has all 5 variables
- ssh.sh created with correct variables
- ssh.sh in .gitignore
- staging.key in .gitignore
- lazygit uploaded and assume-unchanged
- SSH key management works (test appropriate case)
- staging.key marked assume-unchanged
- ssh-add succeeds
- db:wipe runs
- db-sync runs
Cleanup After Testing
# Remove test project locally
rm -rf LOCAL_FOLDER
# On server, if you modified SSH keys:
# Restore original keys or regenerate
# Remove any test databases