|
1 |
| -import * as core from "@actions/core" |
2 | 1 | import * as fs from "fs"
|
3 | 2 | import * as path from "path"
|
4 | 3 | import * as handlers from "typed-rest-client/Handlers"
|
@@ -109,9 +108,15 @@ afterEach(async () => {
|
109 | 108 | })
|
110 | 109 |
|
111 | 110 | function readFromFile(fileName: string): string {
|
112 |
| - return fs.readFileSync(`${__dirname}/resource/${fileName}`, { |
| 111 | + const fileContents = fs.readFileSync(`${__dirname}/resource/${fileName}`, { |
113 | 112 | encoding: "utf-8"
|
114 | 113 | })
|
| 114 | + return normalizeLineEndings(fileContents) |
| 115 | +} |
| 116 | + |
| 117 | +function normalizeLineEndings(str: string): string { |
| 118 | + // Normalize all line endings to LF (\n) |
| 119 | + return str.replace(/\r\n/g, "\n") |
115 | 120 | }
|
116 | 121 |
|
117 | 122 | test("Download all files from public repo", async () => {
|
@@ -315,11 +320,16 @@ test("Download all archive files from public repo", async () => {
|
315 | 320 | fs.existsSync(path.join(downloadSettings.outFilePath, "test-3.txt"))
|
316 | 321 | ).toBe(true)
|
317 | 322 |
|
318 |
| - const test4actual = path.join(downloadSettings.outFilePath, "test-4.txt") |
319 |
| - expect(fs.existsSync(test4actual)).toBe(true) |
320 |
| - expect(fs.readFileSync(test4actual, {encoding: "utf-8"}).toString()).toBe( |
321 |
| - readFromFile("assets/archive-example-test-4.txt") |
| 323 | + const extractedFilePath = path.join( |
| 324 | + downloadSettings.outFilePath, |
| 325 | + "test-4.txt" |
322 | 326 | )
|
| 327 | + expect(fs.existsSync(extractedFilePath)).toBe(true) |
| 328 | + |
| 329 | + const actualContent = fs.readFileSync(extractedFilePath, {encoding: "utf-8"}) |
| 330 | + const expectedContent = readFromFile("assets/archive-example-test-4.txt") |
| 331 | + |
| 332 | + expect(normalizeLineEndings(actualContent)).toBe(expectedContent) |
323 | 333 | }, 10000)
|
324 | 334 |
|
325 | 335 | test("Fail when a release with no assets are obtained", async () => {
|
|
0 commit comments