This project uses environment variables for test credentials, which allows:
- Local testing with a
.envfile - CI/CD testing with secrets
- No modification of user preferences during tests
-
Copy the distribution environment file:
cp .env.dist .env
-
Edit
.envwith your test credentials:# SpeleoDB instance URL (without trailing slash) TEST_SPELEODB_INSTANCE=https://www.speleoDB.org # OAuth token (40 character hexadecimal) TEST_SPELEODB_OAUTH=your_actual_token_here
-
Run the tests:
# Test EVERYTHING (Rust tests + WASM UI) # All tests use real HTTP requests to your server make test # Or just Rust tests make test-rust # Or directly with cargo cargo test --workspace --exclude speleodb-compass-sidecar-ui
Or for specific test targets:
# Test only the Tauri backend make test-tauri # Test only the common crate make test-common # Test only WASM UI make test-ui # Test with output visible make test-rust-verbose
Tests will:
- Authenticate with your real API
- Fetch real project data
- Test error handling with invalid credentials
- All using real HTTP requests - no mocking
The project includes two GitHub Actions workflows:
-
.github/workflows/ci.yml- Runs tests on every push and pull request- Executes
make test(all Rust + WASM UI tests) - Runs on Windows (matching the publish environment)
- Uses caching for faster builds (Rust, cargo bins, trunk artifacts)
- Executes
-
.github/workflows/publish.yml- Publishes the app- Automatically runs CI tests first (via
needs: test) - Only publishes if all tests pass
- Creates GitHub releases with built artifacts
- Automatically runs CI tests first (via
Set these environment variables as repository secrets in GitHub:
TEST_SPELEODB_INSTANCE- Your SpeleoDB instance URLTEST_SPELEODB_OAUTH- Your OAuth token for testing
To add secrets:
- Go to your repository → Settings → Secrets and variables → Actions
- Click "New repository secret"
- Add
TEST_SPELEODB_INSTANCEandTEST_SPELEODB_OAUTH
If secrets are not set, the workflow will use default placeholder values (tests may fail if they require real API access).
Push to main/master or PR:
├─ CI Tests workflow runs automatically
│ ├─ Setup environment (Node, Rust, wasm-pack, trunk)
│ ├─ Run `make test`
│ └─ Report results
Push to main/master with tags:
├─ CI Tests workflow runs first
├─ If tests pass ✓
│ └─ Publish workflow runs
│ └─ Build and release artifacts
└─ If tests fail ✗
└─ Publish workflow is skipped
You can also manually trigger the CI workflow from the Actions tab in GitHub.
-
Tests load
.envautomatically: The test suite uses thedotenvycrate to load environment variables from.envbefore running tests. -
Real HTTP requests only: All tests make actual HTTP requests to your SpeleoDB server. There are no mocks or fake servers.
-
Fallback to user preferences: The
fetch_projectscommand checks for environment variables first. If not found, it falls back to user preferences (for production use). -
No test pollution: Tests use environment variables instead of saving to user preferences, preventing test data from affecting your local development environment.
All tests make real HTTP requests to your SpeleoDB instance. There are no mocks.
Requirements:
- A running SpeleoDB server (set in
TEST_SPELEODB_INSTANCE) - Valid OAuth token (set in
TEST_SPELEODB_OAUTH)
- Application directory management
- File logger initialization
- Path utilities
- Basic commands (greet)
- Token parsing (8 tests)
- User preferences (5 tests) - uses
#[serial] - Authentication (6 tests)
- Projects API (3 tests) - uses
#[serial]
# Run only authentication tests
cargo test native_auth_request
# Run only project fetching tests
cargo test fetch_projects
# Run with output
cargo test -- --nocapture
# Run tests serially (slower but prevents race conditions)
cargo test -- --test-threads=1The project includes helpful Makefile targets for common tasks:
make test- Test EVERYTHING (Rust + WASM UI) - default - uses real APImake test-rust- Run only Rust tests (backend + common crate) - uses real APImake test-rust-verbose- Run Rust tests with output visible (--nocapture)make test-tauri- Run only Tauri backend tests - uses real APImake test-common- Run only common crate testsmake test-ui- Run only WASM UI tests (requires wasm-pack)make check-env- Verify.envfile exists
make build- Build the project (legacy flit)make build-tauri- Build the Tauri applicationmake build-ui- Build UI for distribution with trunk
make dev- Run development server with hot-reloadmake check-env- Verify.envfile existsmake clean- Remove build artifacts
.envis in.gitignoreand will never be committed.env.distis the distribution template (committed to git)- Tests that modify shared state use the
#[serial]attribute to prevent race conditions - All tests use real HTTP requests - no mocks, no fake servers
- Tests require a running SpeleoDB instance at
TEST_SPELEODB_INSTANCE