Skip to content

Commit aef1781

Browse files
ldanilekConvex, Inc.
authored and
Convex, Inc.
committed
make LogLines proptest infallible (#24186)
ask for a number in the desired range instead of asking for any number and filtering out GitOrigin-RevId: c0683f6d5c3a1d152f4d91ad7ff9a84efb05e86a
1 parent ee980c9 commit aef1781

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

crates/common/src/log_lines.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,21 +151,17 @@ impl Arbitrary for LogLine {
151151
prop::collection::vec(any::<String>(), 1..4),
152152
any::<LogLevel>(),
153153
any::<bool>(),
154-
any::<i64>(),
154+
(u64::MIN..(i64::MAX as u64)),
155155
any::<Option<SystemLogMetadata>>()
156156
)
157-
.prop_filter_map(
158-
"Invalid LogLine",
157+
.prop_map(
159158
|(messages, level, is_truncated, timestamp_ms, system_metadata)| {
160-
match u64::try_from(timestamp_ms) {
161-
Ok(timestamp_ms) => Some(LogLine::Structured {
162-
messages: messages.into(),
163-
level,
164-
is_truncated,
165-
timestamp: UnixTimestamp::from_millis(timestamp_ms),
166-
system_metadata,
167-
}),
168-
Err(_) => None,
159+
LogLine::Structured {
160+
messages: messages.into(),
161+
level,
162+
is_truncated,
163+
timestamp: UnixTimestamp::from_millis(timestamp_ms),
164+
system_metadata,
169165
}
170166
}
171167
)

0 commit comments

Comments
 (0)