Skip to content

Commit

Permalink
chore: update versions for refs (#4271)
Browse files Browse the repository at this point in the history
* chore: update versions for refs

* fix: update `fluvio-smartengine` version

* fix: test config file
  • Loading branch information
EstebanBorai authored Nov 22, 2024
1 parent f94bc1a commit 1eec590
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/fluvio-smartengine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fluvio-smartengine"
version = "0.8.2"
version = "0.8.3"
edition = "2021"
license = "Apache-2.0"
authors = ["Fluvio Contributors <[email protected]>"]
Expand Down
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
6 changes: 3 additions & 3 deletions crates/fluvio-smartengine/testdata/transformation/full.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
transforms:
- uses: infinyon/jolt@0.1.0
- uses: infinyon/jolt@0.4.1
lookback:
age: 1w
with:
Expand All @@ -12,7 +12,7 @@ transforms:
spec:
device:
type: "mobile"
- uses: infinyon/jolt@0.1.0
- uses: infinyon/jolt@0.4.1
lookback:
last: 1
with:
Expand All @@ -25,7 +25,7 @@ transforms:
spec:
device:
type: "mobile"
- uses: infinyon/json-sql@0.1.0
- uses: infinyon/json-sql@0.2.1
lookback:
last: 10
age: 12 s
Expand Down

0 comments on commit 1eec590

Please sign in to comment.