From fbed6dc855bb0eec5131fed8bac2fac768980f4d Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 4 Aug 2025 15:35:46 +0200 Subject: [PATCH] Fix response body validation in task logs tests & improve Windows regexp --- tests/helper/task.go | 2 +- tests/worker/task_logs_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/helper/task.go b/tests/helper/task.go index 99cd69c..e542044 100644 --- a/tests/helper/task.go +++ b/tests/helper/task.go @@ -19,7 +19,7 @@ func init() { switch runtime.GOOS { case "windows": HostsFilePath = "$env:windir/System32/drivers/etc/hosts" - NoFileErrorMessage = "Cannot find path \\r\\n'.+%s' because it does not exist." + NoFileErrorMessage = "Cannot find path (\\r\\n)*'.+%s' because (\\r\\n)*it (\\r\\n)*does (\\r\\n)*not (\\r\\n)*exist." case "linux": HostsFilePath = "/etc/hosts" NoFileErrorMessage = "%s: No such file or directory" diff --git a/tests/worker/task_logs_test.go b/tests/worker/task_logs_test.go index 0c92d0a..30c7081 100644 --- a/tests/worker/task_logs_test.go +++ b/tests/worker/task_logs_test.go @@ -32,7 +32,7 @@ func TestTaskLogs__PrintFile(t *testing.T) { name: "print-non-existing-file", path: "non-existing-file.txt", responseStatus: http.StatusInternalServerError, - responseBody: "", + responseBody: "Error when executing the task: exit status 1", stdoutRegexp: fmt.Sprintf(helper.NoFileErrorMessage, "non-existing-file.txt"), }, } @@ -52,7 +52,7 @@ func TestTaskLogs__PrintFile(t *testing.T) { }) assert.Equal(t, tc.responseStatus, responseRecorder.Code) - assert.Equal(t, tc.responseBody, tc.responseBody) + assert.Equal(t, tc.responseBody, responseRecorder.Body.String()) assert.Regexp(t, tc.stdoutRegexp, stdout) }) }