Skip to content

Commit b566b76

Browse files
ref: add tests for invalid durations (#87361)
I initially thought the parsing here was infallible -- but found these edge cases and added some test coverage <!-- Describe your PR here. -->
1 parent 0b5e044 commit b566b76

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/sentry/api/test_event_search.py

+12
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ def test_duration_measurement_filter(self, mock_type):
429429
),
430430
]
431431

432+
def test_invalid_duration(self):
433+
with pytest.raises(InvalidSearchQuery) as excinfo:
434+
parse_search_query("transaction.duration:>1111111111w")
435+
(msg,) = excinfo.value.args
436+
assert msg == "1111111111w is too large of a value, the maximum value is 999999999 days"
437+
432438
@patch("sentry.search.events.builder.base.BaseQueryBuilder.get_field_type")
433439
def test_aggregate_duration_measurement_filter(self, mock_type):
434440
config = SearchConfig()
@@ -449,6 +455,12 @@ def test_aggregate_duration_measurement_filter(self, mock_type):
449455
),
450456
]
451457

458+
def test_invalid_aggregate_duration(self):
459+
with pytest.raises(InvalidSearchQuery) as excinfo:
460+
parse_search_query("trend_difference():>1111111111w")
461+
(msg,) = excinfo.value.args
462+
assert msg == "1111111111w is too large of a value, the maximum value is 999999999 days"
463+
452464
@patch("sentry.search.events.builder.base.BaseQueryBuilder.get_field_type")
453465
def test_numeric_measurement_filter(self, mock_type):
454466
config = SearchConfig()

0 commit comments

Comments
 (0)