Skip to content

Commit

Permalink
chore: update versions for refs
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai authored Nov 21, 2024
1 parent c61f066 commit db6c604
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions crates/fluvio-smartengine/src/transformation.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::{
collections::BTreeMap,
fmt::{self, Display},
path::PathBuf,
fs::File,
io::Read,
ops::Deref,
time::Duration,
};
use std::collections::BTreeMap;
use std::fmt::{self, Display};
use std::path::PathBuf;
use std::fs::File;
use std::io::Read;
use std::ops::Deref;
use std::time::Duration;

use serde::{
Deserialize, Serialize, Deserializer,
de::{Visitor, self, SeqAccess, MapAccess},
Expand Down Expand Up @@ -197,23 +196,23 @@ mod tests {
TransformationConfig {
transforms: vec![
TransformationStep {
uses: "infinyon/jolt@0.1.0".to_string(),
uses: "infinyon/jolt@0.4.1".to_string(),
lookback: Some(Lookback{ last: 0, age: Some(Duration::from_secs(3600 * 24 * 7)) }),
with: BTreeMap::from([(
"spec".to_string(),
JsonString("[{\"operation\":\"shift\",\"spec\":{\"payload\":{\"device\":\"device\"}}},{\"operation\":\"default\",\"spec\":{\"device\":{\"type\":\"mobile\"}}}]".to_string())
)])
},
TransformationStep {
uses: "infinyon/jolt@0.1.0".to_string(),
uses: "infinyon/jolt@0.4.1".to_string(),
lookback: Some(Lookback{ last: 1, age: None }),
with: BTreeMap::from([(
"spec".to_string(),
JsonString("[{\"operation\":\"shift\",\"spec\":{\"payload\":{\"device\":\"device\"}}},{\"operation\":\"default\",\"spec\":{\"device\":{\"type\":\"mobile\"}}}]".to_string())
)])
},
TransformationStep {
uses: "infinyon/json-sql@0.1.0".to_string(),
uses: "infinyon/json-sql@0.2.1".to_string(),
lookback: Some(Lookback{ last: 10, age: Some(Duration::from_secs(12)) }),
with: BTreeMap::from([(
"mapping".to_string(),
Expand All @@ -240,16 +239,16 @@ mod tests {
fn test_from_vec() {
//given
let vec = vec![
r#"{"uses":"infinyon/jolt@0.1.0","invoke":"insert","with":{"spec":"[{\"operation\":\"remove\",\"spec\":{\"length\":\"\"}}]"}}"#,
r#"{"uses":"infinyon/json-sql@0.1.0","invoke":"insert","with":{"mapping":"{\"table\":\"topic_message_demo\",\"map-columns\":{\"fact\":{\"json-key\":\"fact\",\"value\":{\"type\":\"text\",\"required\":true}},\"record\":{\"json-key\":\"$\",\"value\":{\"type\":\"jsonb\",\"required\":true}}}}"}}"#,
r#"{"uses":"infinyon/jolt@0.4.1","invoke":"insert","with":{"spec":"[{\"operation\":\"remove\",\"spec\":{\"length\":\"\"}}]"}}"#,
r#"{"uses":"infinyon/json-sql@0.2.1","invoke":"insert","with":{"mapping":"{\"table\":\"topic_message_demo\",\"map-columns\":{\"fact\":{\"json-key\":\"fact\",\"value\":{\"type\":\"text\",\"required\":true}},\"record\":{\"json-key\":\"$\",\"value\":{\"type\":\"jsonb\",\"required\":true}}}}"}}"#,
];

//when
let config = TransformationConfig::try_from(vec).expect("transformation config");

//then
assert_eq!(config.transforms.len(), 2);
assert_eq!(config.transforms[0].uses, "infinyon/jolt@0.1.0");
assert_eq!(config.transforms[0].uses, "infinyon/jolt@0.4.1");
assert_eq!(
config.transforms[0].with,
BTreeMap::from([(
Expand All @@ -258,7 +257,7 @@ mod tests {
)])
);

assert_eq!(config.transforms[1].uses, "infinyon/json-sql@0.1.0");
assert_eq!(config.transforms[1].uses, "infinyon/json-sql@0.2.1");
assert_eq!(
config.transforms[1].with,
BTreeMap::from([(
Expand Down

0 comments on commit db6c604

Please sign in to comment.