Skip to content

Conversation

@JanZachmann
Copy link
Contributor

Summary

Add comprehensive unit tests for OmnectDeviceServiceClient to validate client configuration, URL building, version requirements, and state tracking.

Tests Added (15)

URL Building (5 tests)

  • ✅ Normalizes path with leading slash
  • ✅ Normalizes path without leading slash
  • ✅ Normalizes path with multiple leading slashes
  • ✅ Handles empty path
  • ✅ Handles root path

Version Requirements (3 tests)

  • ✅ Parses required version correctly (>=0.39.0)
  • ✅ Matches valid versions (0.39.0, 0.40.0, 1.0.0)
  • ✅ Rejects older versions (0.38.9, 0.30.0, 0.1.0)

Healthcheck Logic (3 tests)

  • ✅ Detects version mismatch when below requirement
  • ✅ Detects no mismatch when matching requirement
  • ✅ Includes network rollback status

Publish Endpoint State (2 tests)

  • ✅ New client has no publish endpoint
  • ✅ Client tracks publish endpoint registration

Constants (2 tests)

  • ✅ API endpoints are correctly defined
  • ✅ Required version constant is valid semver

Implementation Details

  • Tests focus on pure logic without requiring HTTP/Unix socket connections
  • Version matching uses semver crate for validation
  • URL building tested with edge cases (empty, multiple slashes, etc.)
  • Constants validated to prevent typos in API paths

Test Results

cargo test --features mock omnect_device_service_client::tests

All 15 tests pass ✅

Impact

  • Total backend tests: 60 → 75 (+15)
  • Coverage: Device service client configuration & version validation
  • Phase: 1.4 of backend test plan (completes Phase 1)

Checklist

  • All tests pass
  • Code formatted with cargo fmt
  • Clippy passes
  • BACKEND_TEST_CONCEPT.md updated
  • Phase 1 complete

Signed-off-by: Jan Zachmann 50990105+JanZachmann@users.noreply.github.com

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
- Implemented auth.spec.ts, device.spec.ts, network.spec.ts
- Added centrifugo fixture helper
- Fixed Centrifugo subscription in App.vue
- Improved test scripts for argument forwarding
- Configured playwright to ignore HTTPS errors
- Added jsonwebtoken for test token generation

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Add comprehensive unit tests for NetworkConfigService covering:
- Request validation (DHCP, static IP, netmask boundaries)
- INI file generation for systemd-networkd
- Rollback response structure
- camelCase serialization/deserialization
- enable_rollback field handling

Tests use tempfile for filesystem operations and replicate
production INI generation logic in isolation.

Note: Rollback file I/O tests not included due to hardcoded
paths (/network/, /tmp/). Would require path injection refactor.

14 tests added, bringing total backend tests from 40 to 54.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Expand firmware service test coverage to validate file operations
and device service delegation:
- clear_data_folder removes files, preserves subdirectories
- load_update forwards requests to device service client
- run_update forwards requests with validation flag

Tests use mockall to mock DeviceServiceClient for async operations.

Note: clear_data_folder tests share temp directory and may race
in parallel. Run with --test-threads=1 if flaky.

7 tests total (6 new), bringing backend tests from 54 to 60.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Add comprehensive unit tests for OmnectDeviceServiceClient covering:
- URL building and path normalization
- Semver version requirement parsing and matching
- Version mismatch detection for healthcheck
- Publish endpoint state tracking
- API endpoint constants validation

Tests validate client logic without requiring actual HTTP calls
or Unix socket connections.

15 tests added, bringing total backend tests from 60 to 75.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant