From 8b352484d82266a8401dbaf04b6dd98b6e7f8e00 Mon Sep 17 00:00:00 2001 From: naiba Date: Mon, 20 Jul 2026 17:32:49 +0000 Subject: [PATCH] test(agentcompat): preserve existing CRLF workflow data Co-authored-by: naiba/CloudCode --- .../required_aggregator_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/integration/agentcompat/internal/workflowpolicy/required_aggregator_test.go b/integration/agentcompat/internal/workflowpolicy/required_aggregator_test.go index 2a1b0409..80c470fb 100644 --- a/integration/agentcompat/internal/workflowpolicy/required_aggregator_test.go +++ b/integration/agentcompat/internal/workflowpolicy/required_aggregator_test.go @@ -30,7 +30,7 @@ func TestPolicy_RejectsInvalidRequiredAggregator(t *testing.T) { data []byte }{ {name: "LF", data: workflowData}, - {name: "CRLF", data: []byte(strings.ReplaceAll(string(workflowData), "\n", "\r\n"))}, + {name: "CRLF", data: []byte(workflowWithCRLF(string(workflowData)))}, } tests := []struct { name string @@ -108,6 +108,23 @@ func TestPolicy_RejectsInvalidRequiredAggregator(t *testing.T) { } } +func TestWorkflowWithCRLF_PreservesExistingCRLF(t *testing.T) { + // Given + workflow := "first\r\nsecond\r\n" + + // When + converted := workflowWithCRLF(workflow) + + // Then + require.Equal(t, workflow, converted) +} + +func workflowWithCRLF(workflow string) string { + // Normalize first so Windows checkouts are not expanded from CRLF to CRCRLF. + workflow = strings.ReplaceAll(workflow, "\r\n", "\n") + return strings.ReplaceAll(workflow, "\n", "\r\n") +} + func mutateWorkflow(t *testing.T, data []byte, currentText, invalidText string) string { t.Helper() workflow := string(data)