Skip to content

Commit 718f61b

Browse files
authored
test: add tests for cw logs (getsentry#622)
* test: add tests for cw logs * style: log_group != log_stream
1 parent 47f4a7a commit 718f61b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/integrations/aws_lambda/test_aws.py

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import base64
22
import json
33
import os
4+
import re
45
import shutil
56
import subprocess
67
import sys
@@ -146,6 +147,18 @@ def test_handler(event, context):
146147

147148
assert event["extra"]["lambda"]["function_name"].startswith("test_function_")
148149

150+
logs_url = event["extra"]["cloudwatch logs"]["url"]
151+
assert logs_url.startswith("https://console.aws.amazon.com/cloudwatch/home?region=")
152+
assert not re.search("(=;|=$)", logs_url)
153+
assert event["extra"]["cloudwatch logs"]["log_group"].startswith(
154+
"/aws/lambda/test_function_"
155+
)
156+
157+
log_stream_re = "^[0-9]{4}/[0-9]{2}/[0-9]{2}/\\[[^\\]]+][a-f0-9]+$"
158+
log_stream = event["extra"]["cloudwatch logs"]["log_stream"]
159+
160+
assert re.match(log_stream_re, log_stream)
161+
149162

150163
def test_initialization_order(run_lambda_function):
151164
"""Zappa lazily imports our code, so by the time we monkeypatch the handler

0 commit comments

Comments
 (0)