Server: domain (entities, value objects, ports), protocol (postcard wire types), application (config service, data projection), adapters (config-memory, tcp-server), bootstrap (composition root with fake data). Client: client-domain (layout engine, render tree, HAL ports), client-application (message handling, repaint commands), adapters (tcp-client, display-terminal), client-desktop (end-to-end working). ESP32: client-esp32 firmware with ILI9341 display over SPI, WiFi networking. Display test verified on hardware — landscape orientation, text rendering works. 60 workspace tests, all passing.
52 lines
1.6 KiB
Rust
52 lines
1.6 KiB
Rust
use std::time::Duration;
|
|
use domain::{DataSource, DataSourceConfig, DataSourceType, DataSourceValidationError};
|
|
|
|
fn make_source(source_type: DataSourceType, url: Option<&str>, poll: Duration) -> DataSource {
|
|
DataSource {
|
|
id: 1,
|
|
name: "test".into(),
|
|
source_type,
|
|
poll_interval: poll,
|
|
config: DataSourceConfig {
|
|
url: url.map(Into::into),
|
|
headers: vec![],
|
|
api_key: None,
|
|
},
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn http_json_requires_url() {
|
|
let source = make_source(DataSourceType::HttpJson, None, Duration::from_secs(60));
|
|
let errors = source.validate();
|
|
assert!(errors.contains(&DataSourceValidationError::UrlRequired));
|
|
}
|
|
|
|
#[test]
|
|
fn webhook_does_not_allow_poll_interval() {
|
|
let source = make_source(DataSourceType::Webhook, None, Duration::from_secs(60));
|
|
let errors = source.validate();
|
|
assert!(errors.contains(&DataSourceValidationError::PollIntervalNotAllowed));
|
|
}
|
|
|
|
#[test]
|
|
fn webhook_with_zero_interval_is_valid() {
|
|
let source = make_source(DataSourceType::Webhook, None, Duration::ZERO);
|
|
let errors = source.validate();
|
|
assert!(errors.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn poll_based_source_requires_nonzero_interval() {
|
|
let source = make_source(DataSourceType::Weather, Some("https://api.weather.com"), Duration::ZERO);
|
|
let errors = source.validate();
|
|
assert!(errors.contains(&DataSourceValidationError::PollIntervalRequired));
|
|
}
|
|
|
|
#[test]
|
|
fn valid_poll_source_has_no_errors() {
|
|
let source = make_source(DataSourceType::Rss, Some("https://feed.example.com"), Duration::from_secs(300));
|
|
let errors = source.validate();
|
|
assert!(errors.is_empty());
|
|
}
|