Skip to content

Commit 2dfea9f

Browse files
committed
test(cicd): cover message chunking boundaries
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
1 parent e559225 commit 2dfea9f

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

tests/integrations/github/cicd/test_github_controller.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,15 +917,32 @@ def test_forward_only_config_falls_back_to_plan_config(
917917
assert controller.forward_only_plan is False
918918

919919

920-
def test_chunk_up_api_message_preserves_multibyte_chars(
920+
def test_chunk_up_api_message_preserves_ascii_behavior(
921921
github_client, make_event_issue_comment, make_controller
922922
):
923923
controller = make_controller(make_event_issue_comment("created", "test"), github_client)
924924

925+
max_bytes = controller.MAX_BYTE_LENGTH
926+
message = ("a" * max_bytes) + ("b" * max_bytes) + "c"
927+
928+
assert controller._chunk_up_api_message("") == []
929+
assert controller._chunk_up_api_message(message) == [
930+
"a" * max_bytes,
931+
"b" * max_bytes,
932+
"c",
933+
]
934+
935+
936+
@pytest.mark.parametrize("multibyte_char", ["🙂", "界"])
937+
def test_chunk_up_api_message_preserves_multibyte_chars(
938+
github_client, make_event_issue_comment, make_controller, multibyte_char
939+
):
940+
controller = make_controller(make_event_issue_comment("created", "test"), github_client)
941+
925942
max_bytes = controller.MAX_BYTE_LENGTH
926943
# Place a multibyte character exactly on the byte boundary between two chunks so
927944
# that byte-oriented slicing would bisect its UTF-8 encoding and drop it.
928-
message = ("a" * (max_bytes - 1)) + "é" + ("b" * max_bytes)
945+
message = ("a" * (max_bytes - 1)) + multibyte_char + "b"
929946
assert len(message.encode("utf-8")) > max_bytes
930947

931948
chunks = controller._chunk_up_api_message(message)

0 commit comments

Comments
 (0)