From 1860decefb642344bd07d58df158486c3f84780b Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 14 Nov 2019 16:45:51 -0500 Subject: [PATCH] Arrange args in restore tests --- __tests__/restore.test.ts | 48 ++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index d2f7dd8..1919e30 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -263,12 +263,16 @@ test("restore with cache found", async () => { expect(mkdirMock).toHaveBeenCalledWith(cachePath); const IS_WINDOWS = process.platform === "win32"; - const tarArchivePath = IS_WINDOWS - ? archivePath.replace(/\\/g, "/") - : archivePath; - const tarCachePath = IS_WINDOWS ? cachePath.replace(/\\/g, "/") : cachePath; - const args = IS_WINDOWS ? ["-xz", "--force-local"] : ["-xz"]; - args.push(...["-f", tarArchivePath, "-C", tarCachePath]); + const args = IS_WINDOWS + ? [ + "-xz", + "--force-local", + "-f", + archivePath.replace(/\\/g, "/"), + "-C", + cachePath.replace(/\\/g, "/") + ] + : ["-xz", "-f", archivePath, "-C", cachePath]; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith(`"tar"`, args); @@ -340,12 +344,16 @@ test("restore with a pull request event and cache found", async () => { expect(mkdirMock).toHaveBeenCalledWith(cachePath); const IS_WINDOWS = process.platform === "win32"; - const tarArchivePath = IS_WINDOWS - ? archivePath.replace(/\\/g, "/") - : archivePath; - const tarCachePath = IS_WINDOWS ? cachePath.replace(/\\/g, "/") : cachePath; - const args = IS_WINDOWS ? ["-xz", "--force-local"] : ["-xz"]; - args.push(...["-f", tarArchivePath, "-C", tarCachePath]); + const args = IS_WINDOWS + ? [ + "-xz", + "--force-local", + "-f", + archivePath.replace(/\\/g, "/"), + "-C", + cachePath.replace(/\\/g, "/") + ] + : ["-xz", "-f", archivePath, "-C", cachePath]; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith(`"tar"`, args); @@ -417,12 +425,16 @@ test("restore with cache found for restore key", async () => { expect(mkdirMock).toHaveBeenCalledWith(cachePath); const IS_WINDOWS = process.platform === "win32"; - const tarArchivePath = IS_WINDOWS - ? archivePath.replace(/\\/g, "/") - : archivePath; - const tarCachePath = IS_WINDOWS ? cachePath.replace(/\\/g, "/") : cachePath; - const args = IS_WINDOWS ? ["-xz", "--force-local"] : ["-xz"]; - args.push(...["-f", tarArchivePath, "-C", tarCachePath]); + const args = IS_WINDOWS + ? [ + "-xz", + "--force-local", + "-f", + archivePath.replace(/\\/g, "/"), + "-C", + cachePath.replace(/\\/g, "/") + ] + : ["-xz", "-f", archivePath, "-C", cachePath]; expect(execMock).toHaveBeenCalledTimes(1); expect(execMock).toHaveBeenCalledWith(`"tar"`, args);