Skip to content

Commit 4edf94e

Browse files
committed
Fix response body validation in task logs tests & improve Windows regexp
1 parent f824728 commit 4edf94e

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

tests/helper/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func init() {
1919
switch runtime.GOOS {
2020
case "windows":
2121
HostsFilePath = "$env:windir/System32/drivers/etc/hosts"
22-
NoFileErrorMessage = "Cannot find path \\r\\n'.+%s' because it does not exist."
22+
NoFileErrorMessage = "Cannot find path (\\r\\n)*'.+%s' because (\\r\\n)*it (\\r\\n)*does (\\r\\n)*not (\\r\\n)*exist."
2323
case "linux":
2424
HostsFilePath = "/etc/hosts"
2525
NoFileErrorMessage = "%s: No such file or directory"

tests/worker/task_logs_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestTaskLogs__PrintFile(t *testing.T) {
3232
name: "print-non-existing-file",
3333
path: "non-existing-file.txt",
3434
responseStatus: http.StatusInternalServerError,
35-
responseBody: "",
35+
responseBody: "Error when executing the task: exit status 1",
3636
stdoutRegexp: fmt.Sprintf(helper.NoFileErrorMessage, "non-existing-file.txt"),
3737
},
3838
}
@@ -52,7 +52,7 @@ func TestTaskLogs__PrintFile(t *testing.T) {
5252
})
5353

5454
assert.Equal(t, tc.responseStatus, responseRecorder.Code)
55-
assert.Equal(t, tc.responseBody, tc.responseBody)
55+
assert.Equal(t, tc.responseBody, responseRecorder.Body.String())
5656
assert.Regexp(t, tc.stdoutRegexp, stdout)
5757
})
5858
}

0 commit comments

Comments
 (0)