Add 296 tests across unit and integration test suites to cover the newly extracted crates from the recent refactor commits. Unit tests (270): - windmill-trigger-postgres (96): hex codec, bool parsing, type conversion, relation tracking, replication message parsing, publication data validation - windmill-trigger-http (92): HMAC signature verification for GitHub/Slack/Stripe/TikTok/Twitch/Zoom webhooks, API key auth, Basic Auth, route validation, HTTP method/request type serde - windmill-api-jobs (39): SQL query builder for job listing/counting with filters, pagination, label handling - windmill-trigger (31): TriggerMode serde, query pagination, BaseTriggerData backward compat, HandlerAction, ServerState - windmill-common webhook (7): WebhookMessage serialization tags - worker nativets/postgresql (5): nativets job execution with args/objects/datetime, postgresql query execution Integration tests (26): - backend/tests/triggers.rs: capture config CRUD, capture payload operations, capture API endpoints, HTTP trigger CRUD with mode filtering, all trigger types DB schema validation (websocket, kafka, postgres, nats, sqs), schedule operations Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
58 lines
1.2 KiB
Rust
58 lines
1.2 KiB
Rust
use thiserror::Error;
|
|
|
|
/**
|
|
* This implementation is inspired by Postgres replication functionality
|
|
* from https://github.com/supabase/pg_replicate
|
|
*
|
|
* Original implementation:
|
|
* - https://github.dev/supabase/pg_replicate/blob/main/pg_replicate/src/conversions/bool.rs
|
|
*
|
|
*/
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum ParseBoolError {
|
|
#[error("invalid input value: {0}")]
|
|
InvalidInput(String),
|
|
}
|
|
|
|
pub fn parse_bool(s: &str) -> Result<bool, ParseBoolError> {
|
|
match s {
|
|
"t" => Ok(true),
|
|
"f" => Ok(false),
|
|
_ => Err(ParseBoolError::InvalidInput(s.to_string())),
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_parse_true() {
|
|
assert_eq!(parse_bool("t").unwrap(), true);
|
|
}
|
|
|
|
#[test]
|
|
fn test_parse_false() {
|
|
assert_eq!(parse_bool("f").unwrap(), false);
|
|
}
|
|
|
|
#[test]
|
|
fn test_invalid_true_string() {
|
|
assert!(matches!(
|
|
parse_bool("true"),
|
|
Err(ParseBoolError::InvalidInput(s)) if s == "true"
|
|
));
|
|
}
|
|
|
|
#[test]
|
|
fn test_invalid_empty() {
|
|
assert!(parse_bool("").is_err());
|
|
}
|
|
|
|
#[test]
|
|
fn test_invalid_uppercase() {
|
|
assert!(parse_bool("T").is_err());
|
|
}
|
|
}
|