diff options
author | Vincent Ambo <mail@tazj.in> | 2022-02-18T09·31+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-02-18T11·52+0000 |
commit | af512558e695605fdfc1b3ede407a6067e355e30 (patch) | |
tree | b663042e99d7bbfdc3a1e30600b92ceb89280768 /ops | |
parent | 19a13e08a8d42b4340cc1b303c326e5091c8ae73 (diff) |
test(journaldriver): Add test for serialising timestamps r/3855
Change-Id: I5b769f5974546fd4f4f853111bd17c9d22d73a5e Reviewed-on: https://cl.tvl.fyi/c/depot/+/5310 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'ops')
-rw-r--r-- | ops/journaldriver/src/tests.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/ops/journaldriver/src/tests.rs b/ops/journaldriver/src/tests.rs index 8a07cc6fed9e..391d39947101 100644 --- a/ops/journaldriver/src/tests.rs +++ b/ops/journaldriver/src/tests.rs @@ -22,6 +22,28 @@ fn test_text_entry_serialization() { } #[test] +fn test_timestamped_entry_serialization() { + let timestamp: DateTime<Utc> = "1952-10-07T12:00:00Z".to_string().parse().unwrap(); + let entry = LogEntry { + labels: Value::Null, + timestamp: Some(timestamp), + payload: Payload::TextPayload { + text_payload: "test entry".into(), + }, + severity: None, + }; + + let expected = + "{\"labels\":null,\"timestamp\":\"1952-10-07T12:00:00Z\",\"textPayload\":\"test entry\"}"; + let result = to_string(&entry).expect("serialization failed"); + + assert_eq!( + expected, result, + "Plain text payload should serialize correctly" + ) +} + +#[test] fn test_json_entry_serialization() { let entry = LogEntry { labels: Value::Null, @@ -37,7 +59,7 @@ fn test_json_entry_serialization() { let expected = "{\"labels\":null,\"jsonPayload\":{\"message\":\"JSON test\"}}"; let result = to_string(&entry).expect("serialization failed"); - assert_eq!(expected, result, "JSOn payload should serialize correctly") + assert_eq!(expected, result, "JSON payload should serialize correctly") } #[test] |