Skip to content

Latest commit

 

History

History
135 lines (105 loc) · 3.39 KB

File metadata and controls

135 lines (105 loc) · 3.39 KB

Test Runner Documentation

Overview

All test files have been moved to the tests/ directory for better project structure. A comprehensive test runner has been created to check the entire project.

Project Structure

dbx/
├── tests/                    # All test files (NEW)
│   ├── internal/
│   │   ├── utils/
│   │   │   └── compress_test.go
│   │   ├── db/
│   │   │   ├── backup_types_test.go
│   │   │   ├── connection_test.go
│   │   │   └── sqlite_test.go
│   │   ├── scheduler/
│   │   │   └── scheduler_test.go
│   │   ├── cloud/
│   │   │   └── storage_test.go
│   │   ├── logs/
│   │   │   └── logger_test.go
│   │   └── notify/
│   │       └── slack_test.go
│   └── test_helpers.go       # Reusable test utilities
├── scripts/
│   └── run_tests.go          # Comprehensive test runner
├── test                      # Simple test runner (Linux/Mac)
├── test.bat                  # Simple test runner (Windows)
└── Makefile                  # Updated with test target

Running Tests

Single Command (Recommended)

Windows:

test.bat

Linux/Mac:

./test

Or using Make:

make test

Or directly:

go run scripts/run_tests.go

What the Test Runner Does

  1. Compilation Check: First checks if all code compiles

    • If compilation fails, stops immediately and asks you to fix errors
    • Prevents running tests on broken code
  2. Test Execution: Runs all tests in:

    • ./internal/* (if any remain)
    • ./tests/internal/* (all test files)
  3. Results Reporting: Shows:

    • Pass/fail count per module
    • Total passed/failed tests
    • Detailed failure information
    • List of failed modules
  4. Error Handling:

    • Stops on compilation errors
    • Reports all test failures
    • Exits with error code if tests fail

Example Output

==========================================
  DBX Project Test Suite Runner
==========================================

📦 Step 1: Checking code compilation...
✅ Code compiles successfully

🧪 Step 2: Running all tests...

Testing module: utils
-----------------------------------
✅ utils: 8 passed, 0 failed

Testing module: db
-----------------------------------
✅ db: 15 passed, 0 failed

...

==========================================
  Test Summary
==========================================
Total Passed: 53
Total Failed: 0

Detailed Results:
-----------------------------------
✅ utils: 8 passed, 0 failed
✅ db: 15 passed, 0 failed
✅ scheduler: 4 passed, 0 failed
✅ cloud: 5 passed, 0 failed
✅ logs: 4 passed, 0 failed
✅ notify: 7 passed, 0 failed

✅ All tests passed!

Test Coverage

  • Security: Input validation, path traversal, password security
  • Scalability: Concurrent operations, large files
  • Utility: Core functionality, error handling
  • OOP Standards: Encapsulation, abstraction
  • DRY Principle: Reusable test helpers
  • SOLID Principles: Single responsibility, dependency injection

Notes

  • Test files use package *_test to test packages from outside
  • All tests are isolated and use temporary directories
  • Tests automatically clean up after execution
  • Some tests may skip if external tools are not available (AWS CLI, etc.)