Skip to content

Commit

Permalink
Allow to use only GOCACHE for cache (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
e-korolevskii committed Dec 19, 2022
1 parent bb5ff97 commit 1710640
Show file tree
Hide file tree
Showing 4 changed files with 5,089 additions and 5,054 deletions.
35 changes: 35 additions & 0 deletions __tests__/cache-utils.test.ts
Expand Up @@ -93,6 +93,41 @@ describe('getCacheDirectoryPath', () => {
.then(data => expect(data).toEqual(expectedResult));
});

it('should return path to the cache folder if one command return empty str', async () => {
//Arrange
getExecOutputSpy.mockImplementationOnce((commandLine: string) => {
return new Promise<exec.ExecOutput>(resolve => {
resolve({exitCode: 0, stdout: 'path/to/cache/folder', stderr: ''});
});
});

getExecOutputSpy.mockImplementationOnce((commandLine: string) => {
return new Promise<exec.ExecOutput>(resolve => {
resolve({exitCode: 0, stdout: '', stderr: ''});
});
});

const expectedResult = ['path/to/cache/folder'];

//Act + Assert
return cacheUtils
.getCacheDirectoryPath(validPackageManager)
.then(data => expect(data).toEqual(expectedResult));
});

it('should throw if the both commands return empty str', async () => {
getExecOutputSpy.mockImplementation((commandLine: string) => {
return new Promise<exec.ExecOutput>(resolve => {
resolve({exitCode: 10, stdout: '', stderr: ''});
});
});

//Act + Assert
expect(async () => {
await cacheUtils.getCacheDirectoryPath(validPackageManager);
}).rejects.toThrow();
});

it('should throw if the specified package name is invalid', async () => {
getExecOutputSpy.mockImplementation((commandLine: string) => {
return new Promise<exec.ExecOutput>(resolve => {
Expand Down

0 comments on commit 1710640

Please sign in to comment.