Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pront committed Aug 22, 2023
1 parent 8309d22 commit 942f589
Showing 1 changed file with 119 additions and 1 deletion.
120 changes: 119 additions & 1 deletion src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ mod tests {

#[cfg(all(feature = "sources-stdin", feature = "sinks-console"))]
#[test]
fn generate_basic() {
fn generate_basic_toml() {
let mut opts = Opts {
fragment: false,
expression: "stdin/test_basic/console".to_string(),
Expand Down Expand Up @@ -643,4 +643,122 @@ mod tests {
.to_string())
);
}

#[test]
fn generate_basic_yaml() {
let opts = Opts {
fragment: false,
expression: "demo_logs/remap/console".to_string(),
file: None,
format: Format::Yaml,
};

assert_eq!(
generate_example(&opts, TransformInputsStrategy::Auto).unwrap(),
indoc::indoc! {r#"
data_dir: /var/lib/vector/
sources:
source0:
count: 9223372036854775807
format: json
interval: 1.0
type: demo_logs
decoding:
codec: bytes
framing:
method: bytes
transforms:
transform0:
inputs:
- source0
drop_on_abort: false
drop_on_error: false
metric_tag_values: single
reroute_dropped: false
runtime: ast
type: remap
sinks:
sink0:
inputs:
- transform0
target: stdout
type: console
encoding:
codec: json
healthcheck:
enabled: true
uri: null
buffer:
type: memory
max_events: 500
when_full: block
"#}
);
}

#[test]
fn generate_basic_json() {
let opts = Opts {
fragment: false,
expression: "demo_logs/remap/console".to_string(),
file: None,
format: Format::Json,
};

assert_eq!(
generate_example(&opts, TransformInputsStrategy::Auto).unwrap(),
indoc::indoc! {r#"
{
"data_dir": "/var/lib/vector/",
"sources": {
"source0": {
"count": 9223372036854775807,
"format": "json",
"interval": 1.0,
"type": "demo_logs",
"decoding": {
"codec": "bytes"
},
"framing": {
"method": "bytes"
}
}
},
"transforms": {
"transform0": {
"inputs": [
"source0"
],
"drop_on_abort": false,
"drop_on_error": false,
"metric_tag_values": "single",
"reroute_dropped": false,
"runtime": "ast",
"type": "remap"
}
},
"sinks": {
"sink0": {
"inputs": [
"transform0"
],
"target": "stdout",
"type": "console",
"encoding": {
"codec": "json"
},
"healthcheck": {
"enabled": true,
"uri": null
},
"buffer": {
"type": "memory",
"max_events": 500,
"when_full": "block"
}
}
}
}"#}
);
}
}

0 comments on commit 942f589

Please sign in to comment.