This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add additional read commands to Makefile * Add .DS_Store to .gitignore * Fix tests
- Loading branch information
Showing
20 changed files
with
120 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
.vscode/* | ||
!.vscode/settings.json | ||
.env | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,39 @@ | ||
import * as core from '@actions/core' | ||
import * as tc from '@actions/tool-cache' | ||
import fs from 'fs' | ||
import { addPath } from '@actions/core' | ||
import { cacheDir } from '@actions/tool-cache' | ||
import { chmodSync } from 'fs' | ||
import path from 'path' | ||
import { restore, SinonStub, stub } from 'sinon' | ||
import Cache from '../Cache' | ||
|
||
describe('Cache', () => { | ||
let addPathStub: SinonStub<[inputPath: string], void> | ||
let cacheDirStub: SinonStub<[sourceDir: string, | ||
tool: string, version: string, arch?: string], Promise<string>> | ||
let chmodSyncStub: SinonStub<[path: fs.PathLike, mode: fs.Mode], void> | ||
|
||
beforeEach(() => { | ||
addPathStub = stub(core, 'addPath') | ||
cacheDirStub = stub(tc, 'cacheDir') | ||
chmodSyncStub = stub(fs, 'chmodSync') | ||
}) | ||
jest.mock('@actions/core', () => ({ addPath: jest.fn() })); | ||
jest.mock('@actions/tool-cache', () => ({ cacheDir: jest.fn() })); | ||
jest.mock('fs', () => ({ chmodSync: jest.fn() })); | ||
|
||
describe('Cache', () => { | ||
it('should cache successfully', async () => { | ||
const version: string = 'ey1r6c00' | ||
const exeFileName: string = 'O7DF0gox' | ||
const getExeFileNameMock: jest.Mock<string, []> = jest.fn(() => exeFileName) | ||
const folderPath: string = '1ef84ehe' | ||
const execFilePath: string = path.join(folderPath, 'm8x9p1sw') | ||
const cachedPath: string = '1r4wn1iw' | ||
cacheDirStub.returns(Promise.resolve(cachedPath)) | ||
const cachedPath: string = '1r4wn1iw'; | ||
(cacheDir as jest.Mock) | ||
.mockImplementation(() => Promise.resolve(cachedPath)) | ||
const cache: Cache = new Cache(version, { | ||
getExeFileName: getExeFileNameMock | ||
}) | ||
await cache.cache(execFilePath) | ||
|
||
expect(getExeFileNameMock.mock.calls.length).toBe(1) | ||
expect(chmodSyncStub.withArgs(execFilePath, '777').callCount).toBe(1) | ||
expect(cacheDirStub.withArgs(folderPath, exeFileName, version).callCount) | ||
.toBe(1) | ||
expect(addPathStub.withArgs(cachedPath).callCount).toBe(1) | ||
expect((chmodSync as jest.Mock).mock.calls.length).toBe(1) | ||
expect(chmodSync).toHaveBeenCalledWith(execFilePath, '777') | ||
expect((addPath as jest.Mock).mock.calls.length).toBe(1) | ||
expect((cacheDir as jest.Mock).mock.calls.length).toBe(1) | ||
expect(cacheDir).toHaveBeenCalledWith(folderPath, exeFileName, version) | ||
}) | ||
|
||
afterEach(() => restore()) | ||
afterEach(() => { | ||
(addPath as jest.Mock).mockClear(), | ||
(cacheDir as jest.Mock).mockClear(), | ||
(chmodSync as jest.Mock).mockClear() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
import * as tc from '@actions/tool-cache' | ||
import fs from 'fs' | ||
import { restore, SinonStub, stub } from 'sinon' | ||
import { downloadTool } from '@actions/tool-cache' | ||
import { renameSync } from 'fs' | ||
import { CLI_EXTENSION } from '../consts' | ||
import Downloader from '../Downloader' | ||
|
||
describe('Downloader', () => { | ||
let fsRenameSyncStub: | ||
SinonStub<[oldPath: fs.PathLike, newPath: fs.PathLike], void> | ||
let downloadToolStub: SinonStub | ||
|
||
beforeEach(() => { | ||
fsRenameSyncStub = stub(fs, 'renameSync') | ||
downloadToolStub = stub(tc, 'downloadTool') | ||
}) | ||
jest.mock('@actions/tool-cache', () => ({ downloadTool: jest.fn() })) | ||
jest.mock('fs', () => ({ renameSync: jest.fn() })) | ||
|
||
describe('Downloader', () => { | ||
it('should download successfully', async () => { | ||
const zipPathOld: string = 'yw86z9qw' | ||
const zipPathNew: string = zipPathOld + '.zip' | ||
const url: string = '9r1y2ryp' | ||
downloadToolStub.returns(Promise.resolve(zipPathOld)) | ||
const zipPathNew: string = zipPathOld + '.' + CLI_EXTENSION | ||
const url: string = '9r1y2ryp'; | ||
(downloadTool as jest.Mock) | ||
.mockImplementation(() => Promise.resolve(zipPathOld)) | ||
const d: Downloader = new Downloader() | ||
const actual: string = await d.download(url) | ||
expect(fsRenameSyncStub.withArgs(zipPathOld, zipPathNew).callCount).toBe(1) | ||
expect((renameSync as jest.Mock).mock.calls.length).toBe(1) | ||
expect(renameSync).toHaveBeenCalledWith(zipPathOld, zipPathNew) | ||
expect(actual).toBe(zipPathNew) | ||
}) | ||
|
||
afterEach(() => restore()) | ||
afterEach(() => { | ||
(downloadTool as jest.Mock).mockClear(); | ||
(renameSync as jest.Mock).mockClear() | ||
}) | ||
}) |
Oops, something went wrong.