QUICK TEST REFERENCE - nself-org/cli GitHub Wiki
# Billing System (150 tests) - ~15 seconds
bash src/tests/integration/test-billing-comprehensive.sh
# OAuth Providers (80 tests) - ~8 seconds
bash src/tests/integration/test-oauth-providers-comprehensive.sh
# White-Label System (100 tests) - ~10 seconds
bash src/tests/integration/test-whitelabel-comprehensive.sh
# Backup/Restore (50 tests) - ~5 seconds
bash src/tests/integration/test-backup-restore-comprehensive.sh
# Rate Limiting (30 tests) - ~3 seconds
bash src/tests/integration/test-rate-limit-comprehensive.sh# Run all 410 new comprehensive tests (~41 seconds)
for test in src/tests/integration/test-*-comprehensive.sh; do
bash "$test"
done# Run complete test suite (855+ tests)
bash src/tests/run-tests.sh| Feature | Tests | File |
|---|---|---|
| Billing | 150 | test-billing-comprehensive.sh |
| OAuth | 80 | test-oauth-providers-comprehensive.sh |
| White-Label | 100 | test-whitelabel-comprehensive.sh |
| Backup/Restore | 50 | test-backup-restore-comprehensive.sh |
| Rate Limiting | 30 | test-rate-limit-comprehensive.sh |
| TOTAL NEW | 410 | 5 new files |
| TOTAL ALL | 855+ | 41 files |
- โ Subscription lifecycle (create, upgrade, downgrade, cancel, reactivate, pause, resume)
- โ Usage tracking & metering (API calls, storage, bandwidth, compute, etc.)
- โ Invoice generation & payment processing
- โ Quota enforcement (soft/hard limits, burst allowance)
- โ Cost allocation & reporting
- โ Stripe integration edge cases
- โ All 13 providers: Google, GitHub, Microsoft, Facebook, Apple, Slack, Discord, Twitch, Twitter, LinkedIn, GitLab, Bitbucket, Spotify
- โ Authorization flows (complete OAuth cycle)
- โ Token refresh mechanisms
- โ Account linking scenarios
- โ Provider failure handling
- โ PKCE support for mobile apps
- โ State validation & security
- โ Branding configuration (logos, colors, fonts)
- โ Domain management (custom domains, SSL, DNS)
- โ Email template customization
- โ Theme management (dark/light modes, CSS variables)
- โ Multi-tenant isolation
- โ Backup creation (full, incremental, encrypted)
- โ Cloud providers (S3, GCS, Azure, Backblaze B2)
- โ Intelligent pruning (age, count, size, GFS rotation)
- โ 3-2-1 rule verification
- โ Cross-environment restore
- โ Corruption handling
- โ Nginx integration (limit_req, limit_conn)
- โ Whitelist/blacklist management
- โ Per-zone rate limits (API, Auth, GraphQL, etc.)
- โ Redis backend
- โ Violation handling & resets
All tests use consistent output formatting:
=== Test Suite Name ===
--- Section Name ---
Test 1: Description... โ passed
Test 2: Description... โ passed
Test 3: Description... โ failed
Expected: value1
Actual: value2
Test Summary
Total Tests: 150
Passed: 149
Failed: 1
Success Rate: 99.3%
โ All tests passed!
All tests are designed to run in CI/CD pipelines:
- Cross-platform: macOS, Linux, WSL
- POSIX-compliant: No Bash 4+ features
- Fast execution: Mock mode completes in seconds
- No external dependencies: Tests use mocks by default
- Exit codes: 0 = success, 1 = failure
- name: Run Billing Tests
run: bash src/tests/integration/test-billing-comprehensive.sh
- name: Run OAuth Tests
run: bash src/tests/integration/test-oauth-providers-comprehensive.sh
- name: Run White-Label Tests
run: bash src/tests/integration/test-whitelabel-comprehensive.sh
- name: Run Backup Tests
run: bash src/tests/integration/test-backup-restore-comprehensive.sh
- name: Run Rate Limiting Tests
run: bash src/tests/integration/test-rate-limit-comprehensive.shTests currently use mock mode for rapid development:
- Mock Stripe API calls
- Mock OAuth provider responses
- Mock cloud storage uploads
- Mock Redis operations
To switch to real testing:
- Set environment variables (e.g.,
STRIPE_API_KEY) - Tests will automatically detect and use real APIs
- Requires real service credentials
# Run relevant test suite to see expected behavior
bash src/tests/integration/test-billing-comprehensive.sh# Run tests frequently to verify progress
bash src/tests/integration/test-billing-comprehensive.sh# Verify all tests pass
bash src/tests/integration/test-billing-comprehensive.sh
# Run full test suite
bash src/tests/run-tests.shIf a test fails:
- Check the output - Test framework shows expected vs actual values
- Run test in isolation - Comment out other tests to focus on one
-
Enable verbose mode - Add
set -xat top of test file - Check test prerequisites - Ensure required files/services exist
To add tests to existing suites:
- Add test function following naming convention:
test_feature_name() - Increment
TOTAL_TESTSvariable at top of file - Follow existing test patterns (describe โ run โ pass/fail)
- Use
printfinstead ofecho -e(POSIX compliance) - Make test cross-platform compatible
Example:
test_new_feature() {
describe "Test new feature"
local result
result=$(some_command)
if printf "%s" "$result" | grep -q "expected"; then
pass "New feature working"
else
fail "New feature failed"
fi
}- Update tests when features change
- Add edge cases as bugs are discovered
- Keep mocks simple - Focus on behavior, not implementation
- Document complex tests - Add comments for non-obvious logic
- Run tests before commits - Ensure nothing breaks
| Metric | Target | Current | Status |
|---|---|---|---|
| Total Tests | 700+ | 855+ | โ Exceeded (122%) |
| Coverage % | 80% | ~85% | โ Exceeded |
| Billing Tests | 150 | 150 | โ Complete |
| OAuth Tests | 80 | 80 | โ Complete |
| White-Label Tests | 100 | 100 | โ Complete |
| Backup Tests | 50 | 50 | โ Complete |
| Rate Limit Tests | 30 | 30 | โ Complete |
Q: Why are tests so fast? A: Tests use mocks by default, avoiding slow external API calls.
Q: How do I run tests with real services?
A: Set appropriate environment variables (e.g., STRIPE_API_KEY, AWS_ACCESS_KEY_ID).
Q: Can I run tests in parallel? A: Yes, test files are independent and can run in parallel.
Q: What if a test fails in CI but passes locally? A: Check for platform-specific differences (macOS vs Linux). All tests should be cross-platform.
Q: How do I add a new test suite? A: Copy an existing comprehensive test file, update the test functions, and add to run-all-tests.sh (invoked via run-tests.sh).
Last Updated: 2025-01-31 Version: v0.9.8 Total Tests: 855+ Coverage: ~85%