ERROR AND EDGE CASE COVERAGE - nself-org/cli GitHub Wiki
This document describes the comprehensive error scenario and edge case test coverage for nself.
Test what users actually encounter, not impossible edge cases.
- User Errors - Invalid input, misconfigurations, missing files
- System Errors - Resource limits, permissions, network failures
- State Errors - Invalid state transitions, race conditions
- Boundary Values - Min/max valid inputs, edge cases
- Error Messages - Clarity, actionability, platform compatibility
- Impossible scenarios (defensive programming)
- Third-party library bugs
- Hardware failures
- Cosmic ray bit flips
- 100% coverage of realistic user-facing errors
- Every error has clear, actionable message
- Cross-platform compatibility (macOS, Linux, WSL)
- Fast test execution (<5 minutes total)
- Reliable tests (no flakiness)
Location: /Users/admin/Sites/nself/src/tests/errors/
File: test-installation-errors.sh
| Scenario | Test | Error Message Quality |
|---|---|---|
| Docker not installed | โ | Provides install links for macOS/Linux |
| Docker daemon not running | โ | Platform-specific start commands |
| Insufficient permissions | โ | sudo and usermod solutions |
| Disk space too low | โ | Shows required vs available, cleanup commands |
| Incompatible Docker version | โ | Version requirements, update instructions |
| Port conflicts | โ | lsof/netstat commands, alternative ports |
| Missing dependencies | โ | apt-get/brew install commands |
Coverage: 12 tests
File: test-configuration-errors.sh
| Scenario | Test | Error Message Quality |
|---|---|---|
| Missing .env file | โ | Suggests nself init
|
| Invalid env variable format | โ | Shows correct format with examples |
| Port out of range | โ | Explains 1-65535 range |
| Invalid domain name | โ | Domain name rules and examples |
| Conflicting settings | โ | Shows conflict, multiple solutions |
| Missing required variables | โ | Lists all missing vars |
| Encrypted .env corruption | โ | 3 recovery options with commands |
| Invalid boolean value | โ | Explains true/false requirement |
| Invalid email format | โ | Email regex, valid/invalid examples |
| Invalid URL format | โ | Protocol requirement, examples |
| Example values not changed | โ | Security warning, password generation |
| Production without SSL | โ | Security warning, SSL setup steps |
Coverage: 12 tests
File: test-service-failures.sh
| Scenario | Test | Error Message Quality |
|---|---|---|
| Port already in use | โ | Find process, kill or change port |
| Multiple port conflicts | โ | Lists all conflicts, solutions |
| Container fails to start | โ | View logs, troubleshoot steps |
| Dependency not ready | โ | Explains temporary, auto-recovery |
| Health check timeout | โ | Logs and restart commands |
| Docker image not found | โ | Pull manually, auth instructions |
| Build failure | โ | Failed step, cache clear commands |
| Out of memory | โ | Required vs available, free memory |
| Disk full | โ | Docker cleanup commands, disk check |
| Network connection failed | โ | Network diagnostics |
| DNS resolution failure | โ | Network inspect, troubleshoot |
| Missing env var at runtime | โ | Add var, rebuild steps |
| Volume permission denied | โ | chown/chmod, SELinux fix |
Coverage: 13 tests
Total Error Tests: 37 tests across 3 files
Location: /Users/admin/Sites/nself/src/tests/edge-cases/
File: test-boundary-values.sh
| Category | Tests | Coverage |
|---|---|---|
| Port numbers | 7 | 0, 1, 1023, 1024, 65535, 65536, negative |
| String lengths | 3 | Empty, single char, very long (>1000) |
| Domain names | 5 | Single char, max 253, over 253, label max 63, over 63 |
| Special characters | 2 | Unicode, control characters |
| Numeric boundaries | 2 | Integer overflow, negative zero |
| Boolean values | 1 | true/false vs TRUE/yes/1/0 |
| Email lengths | 2 | Minimum ([email protected]), maximum (320 chars) |
| URL lengths | 2 | Minimum, IE limit (2083 chars) |
Coverage: 24 tests
File: test-state-transitions.sh
| Category | Tests | Coverage |
|---|---|---|
| Idempotency | 4 | Start running, stop stopped, restart stopped, multiple starts |
| Invalid transitions | 3 | Build without init, start without build, deploy without build |
| Rapid state changes | 2 | Rapid start/stop, multiple restarts |
| Error recovery | 2 | Start after crash, interrupted build |
| Concurrent operations | 1 | Build lock prevents simultaneous builds |
| Runtime changes | 2 | Env change while running, compose change detection |
| Partial failures | 1 | Some services start, others fail |
Coverage: 15 tests
File: test-concurrency.sh (to be created)
| Scenario | Test | Expected Behavior |
|---|---|---|
| Multiple starts | โณ | Lock prevents, first wins |
| Simultaneous builds | โณ | Queue or error |
| Concurrent migrations | โณ | Database lock prevents |
| Parallel deployments | โณ | Safety checks prevent |
| File write races | โณ | Atomic operations |
Planned Coverage: 5 tests
File: test-data-integrity.sh (to be created)
| Scenario | Test | Expected Behavior |
|---|---|---|
| Corrupted compose file | โณ | Validation, regeneration |
| Corrupted .env | โณ | Validation, example |
| Corrupted migration | โณ | Checksum verification |
| Corrupted backup | โณ | Integrity check fails gracefully |
| Invalid config syntax | โณ | Parse error with line number |
Planned Coverage: 5 tests
Total Edge Case Tests: 39 tests (current) + 10 planned = 49 tests
src/tests/
โโโ errors/ # Error scenario tests
โ โโโ README.md # Error testing documentation
โ โโโ run-error-tests.sh # Master error test runner
โ โโโ test-installation-errors.sh (12 tests)
โ โโโ test-configuration-errors.sh (12 tests)
โ โโโ test-service-failures.sh (13 tests)
โ
โโโ edge-cases/ # Edge case tests
โ โโโ README.md # Edge case documentation
โ โโโ run-edge-case-tests.sh # Master edge case runner
โ โโโ test-boundary-values.sh (24 tests)
โ โโโ test-state-transitions.sh (15 tests)
โ โโโ test-concurrency.sh (planned - 5 tests)
โ โโโ test-data-integrity.sh (planned - 5 tests)
โ
โโโ unit/
โโโ test-error-messages.sh # Unit tests for error library
./src/tests/errors/run-error-tests.shOutput:
========================================
nself Error Scenario Tests
========================================
Running: test-installation-errors
โ 12/12 tests passed
Running: test-configuration-errors
โ 12/12 tests passed
Running: test-service-failures
โ 13/13 tests passed
========================================
โ All error tests passed!
========================================
./src/tests/edge-cases/run-edge-case-tests.sh./src/tests/errors/test-installation-errors.sh
./src/tests/edge-cases/test-boundary-values.shEvery error message MUST have:
Docker is not running
Not: Error code 0x4E2
Problem:
The 'docker' command could not connect to the Docker daemon.
Fix:
1. Start Docker Desktop:
macOS: open -a Docker
Linux: sudo systemctl start docker
2. Verify Docker is running:
docker ps
macOS:
open -a Docker
Linux:
sudo systemctl start docker
Verify Docker is running:
docker ps
test_error_message_quality() {
local test_name="Error has all required sections"
local output=$(generate_error_message)
# Verify structure
assert_contains "$output" "Problem:" "$test_name: Has problem section"
assert_contains "$output" "Fix:" "$test_name: Has fix section"
assert_contains "$output" "command" "$test_name: Has actionable command"
# Verify no bad patterns
assert_not_contains "$output" "Error code" "$test_name: No error codes"
assert_not_contains "$output" "contact support" "$test_name: No support punt"
}test_boundary_value() {
local test_name="Port 65535 (max valid)"
local port=65535
if validate_port "$port"; then
local result="valid"
else
local result="invalid"
fi
assert_equals "$result" "valid" "$test_name"
}test_idempotent_operation() {
local test_name="Start is idempotent"
start_service
local state1="$STATE"
start_service # Run again
local state2="$STATE"
assert_equals "$state1" "$state2" "$test_name: State unchanged"
}| Category | Tests | Files | Status |
|---|---|---|---|
| Error Scenarios | 37 | 3 | โ Complete |
| Boundary Values | 24 | 1 | โ Complete |
| State Transitions | 15 | 1 | โ Complete |
| Concurrency | 0 | 0 | โณ Planned |
| Data Integrity | 0 | 0 | โณ Planned |
| Total | 76 | 5 | 80% Complete |
| Category | Goal | Current | Status |
|---|---|---|---|
| Installation Errors | 100% | 100% | โ |
| Configuration Errors | 100% | 100% | โ |
| Service Failures | 100% | 100% | โ |
| Boundary Values | 100% | 100% | โ |
| State Transitions | 100% | 100% | โ |
| Concurrency | 100% | 0% | โณ |
| Data Integrity | 100% | 0% | โณ |
Tests run in GitHub Actions on:
- Ubuntu (latest) - Bash 5.x, GNU tools
- macOS (latest) - Bash 3.2, BSD tools
All tests must:
- โ Pass on both Ubuntu and macOS
- โ
Use
printf(notecho -e) - โ Avoid Bash 4+ features
- โ Complete in <30 seconds per file
- โ Clean up temporary files
- โ Not depend on external services
- โ Be deterministic (no flaky tests)
name: Error & Edge Case Tests
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Run error tests
run: ./src/tests/errors/run-error-tests.sh
- name: Run edge case tests
run: ./src/tests/edge-cases/run-edge-case-tests.sh- โ Installation error tests
- โ Configuration error tests
- โ Service failure tests
- โ Boundary value tests
- โ State transition tests
- โณ Concurrency tests (
test-concurrency.sh) - โณ Data integrity tests (
test-data-integrity.sh) - โณ Cleanup/recovery tests (
test-cleanup-recovery.sh)
- โณ Performance degradation tests
- โณ Network failure simulation tests
- โณ Resource exhaustion recovery tests
-
/docs/ERROR-HANDLING.md- Error handling guidelines -
/docs/TESTING.md- General testing guidelines -
/src/tests/errors/README.md- Error test documentation -
/src/tests/edge-cases/README.md- Edge case documentation -
/src/lib/utils/error-messages.sh- Error message library
Last Updated: January 31, 2026 Version: 0.9.8 Status: 80% Complete (76 of 96 planned tests) Test Execution Time: ~2 minutes total