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)