diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-06-17T01·29+0200 |
---|---|---|
committer | Vincent Ambo <github@tazj.in> | 2018-06-17T13·46+0200 |
commit | 87ab3c806c40d565b75c18237494d591282ccbc2 (patch) | |
tree | c2064a0a45ed78417590ae33d2f7643fbe70e8aa /src/tests.rs | |
parent | f626d8843865975e0804a1e04676255d787687a0 (diff) |
feat(main): Parse timestamps out of journald entries
Instead of relying on Stackdriver's ingestion timestamps, parse timestamps out of journal entries and provide those to Stackdriver. If a timestamp could not be parsed out of a log entry, the ingestion time is used as the fallback.
Diffstat (limited to 'src/tests.rs')
-rw-r--r-- | src/tests.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/tests.rs b/src/tests.rs index 623cb6b59981..6840602eca55 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -5,6 +5,7 @@ use serde_json::to_string; fn test_text_entry_serialization() { let entry = LogEntry { labels: Value::Null, + timestamp: None, payload: Payload::TextPayload { text_payload: "test entry".into(), } @@ -20,6 +21,7 @@ fn test_text_entry_serialization() { fn test_json_entry_serialization() { let entry = LogEntry { labels: Value::Null, + timestamp: None, payload: Payload::TextPayload { text_payload: "test entry".into(), } @@ -78,3 +80,12 @@ fn test_json_no_object() { assert_eq!(expected, payload, "Non-object JSON payload should be plain text"); } + +#[test] +fn test_parse_microseconds() { + let input: String = "1529175149291187".into(); + let expected: DateTime<Utc> = "2018-06-16T18:52:29.291187Z" + .to_string().parse().unwrap(); + + assert_eq!(Some(expected), parse_microseconds(input)); +} |