use pipeflow::config::Config;
#[test]
fn test_config_missing_required_source_fields() {
let yaml = r#"
pipeline:
sources:
- id: src1
# type: http_client <-- Missing
config:
url: "http://example.com"
"#;
let result = Config::from_yaml(yaml);
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("missing field `type`"));
}
#[test]
fn test_config_invalid_field_type() {
let yaml = r#"
pipeline:
sources:
- id: src1
type: http_client
output_buffer_size: "big"
"#;
let result = Config::from_yaml(yaml);
assert!(result.is_err());
let err = result.unwrap_err().to_string();
assert!(err.contains("invalid type: string"));
}
#[test]
fn test_config_malformed_yaml() {
let yaml = r#"
pipeline:
sources:
- id: src1
type: http_client
config:
url: "http://example.com"
indentation_error: true
"#;
let result = Config::from_yaml(yaml);
assert!(result.is_err());
}
#[test]
fn test_config_transform_step_invalid_type() {
let yaml = r#"
pipeline:
sources:
- id: src1
type: http_client
transforms:
- id: t1
inputs: [src1]
steps:
- config: {} # Missing 'type'
"#;
let result = Config::from_yaml(yaml);
assert!(result.is_err());
assert!(
result
.unwrap_err()
.to_string()
.contains("missing field `type`")
);
}