Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions rust/cubeorchestrator/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
pub label: Option<String>,
#[serde(rename = "type")]
pub format_type: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -319,3 +321,39 @@
}

pub type JsRawData = Vec<IndexMap<String, DBResponsePrimitive>>;

#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;

#[test]
fn test_dimension_format_custom_numeric() {
let json = json!({"type": "custom-numeric", "value": ".2f"});
let format: DimensionFormat = serde_json::from_value(json).unwrap();

Check warning on line 334 in rust/cubeorchestrator/src/transport.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/cube/cube/rust/cubeorchestrator/src/transport.rs
// Round-trip
let serialized = serde_json::to_value(&format).unwrap();
assert_eq!(serialized, json!({"type": "custom-numeric", "value": ".2f"}));
}

#[test]
fn test_dimension_format_custom_time() {
let json = json!({"type": "custom-time", "value": "%Y-%m-%d %H:%M:%S"});
let format: DimensionFormat = serde_json::from_value(json).unwrap();

Check warning on line 344 in rust/cubeorchestrator/src/transport.rs

View workflow job for this annotation

GitHub Actions / lint

Diff in /home/runner/work/cube/cube/rust/cubeorchestrator/src/transport.rs
// Round-trip
let serialized = serde_json::to_value(&format).unwrap();
assert_eq!(serialized, json!({"type": "custom-time", "value": "%Y-%m-%d %H:%M:%S"}));
}

#[test]
fn test_dimension_format_link() {
let json = json!({"type": "link", "label": "Click"});
let format: DimensionFormat = serde_json::from_value(json).unwrap();

// Round-trip
let serialized = serde_json::to_value(&format).unwrap();
assert_eq!(serialized, json!({"type": "link", "label": "Click"}));
}
}
Loading