Skip to content

Commit 241a335

Browse files
mock os instead of system
1 parent 79b62ad commit 241a335

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

__tests__/setup-go.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ describe('setup-go', () => {
2626
findSpy = jest.spyOn(tc, 'find');
2727
inSpy = jest.spyOn(core, 'getInput');
2828
cnSpy = jest.spyOn(process.stdout, 'write');
29-
platSpy = jest.spyOn(sys, 'getPlatform');
30-
archSpy = jest.spyOn(sys, 'getArch');
29+
platSpy = jest.spyOn(os, 'platform');
30+
archSpy = jest.spyOn(os, 'arch');
3131
dlSpy = jest.spyOn(tc, 'downloadTool');
3232
exSpy = jest.spyOn(tc, 'extractTar');
3333
cacheSpy = jest.spyOn(tc, 'cacheDir');
@@ -78,7 +78,7 @@ describe('setup-go', () => {
7878

7979
it('downloads a version not in the cache', async () => {
8080
platSpy.mockImplementation(() => 'linux');
81-
archSpy.mockImplementation(() => 'amd64');
81+
archSpy.mockImplementation(() => 'x64');
8282

8383
inSpy.mockImplementation(() => '1.13.1');
8484
findSpy.mockImplementation(() => '');
@@ -97,7 +97,7 @@ describe('setup-go', () => {
9797

9898
it('does not find a version that does not exist', async () => {
9999
platSpy.mockImplementation(() => 'linux');
100-
archSpy.mockImplementation(() => 'amd64');
100+
archSpy.mockImplementation(() => 'x64');
101101

102102
inSpy.mockImplementation(() => '9.99.9');
103103
findSpy.mockImplementation(() => '');
@@ -118,8 +118,8 @@ describe('setup-go', () => {
118118
});
119119

120120
it('finds stable match for exact version', async () => {
121-
platSpy.mockImplementation(() => 'windows');
122-
archSpy.mockImplementation(() => 'amd64');
121+
platSpy.mockImplementation(() => 'win32');
122+
archSpy.mockImplementation(() => 'x64');
123123

124124
// get request is already mocked
125125
// spec: 1.13.7 => 1.13.7 (exact)
@@ -133,7 +133,7 @@ describe('setup-go', () => {
133133

134134
it('finds stable match for exact dot zero version', async () => {
135135
platSpy.mockImplementation(() => 'darwin');
136-
archSpy.mockImplementation(() => 'amd64');
136+
archSpy.mockImplementation(() => 'x64');
137137

138138
// spec: 1.13.0 => 1.13
139139
let match: im.IGoVersion | undefined = await im.findMatch('1.13.0', true);
@@ -146,7 +146,7 @@ describe('setup-go', () => {
146146

147147
it('finds latest patch version for minor version spec', async () => {
148148
platSpy.mockImplementation(() => 'linux');
149-
archSpy.mockImplementation(() => 'amd64');
149+
archSpy.mockImplementation(() => 'x64');
150150
core.debug('plat mocks ok');
151151

152152
// spec: 1.13 => 1.13.7 (latest)
@@ -160,7 +160,7 @@ describe('setup-go', () => {
160160

161161
it('finds latest patch version for caret version spec', async () => {
162162
platSpy.mockImplementation(() => 'linux');
163-
archSpy.mockImplementation(() => 'amd64');
163+
archSpy.mockImplementation(() => 'x64');
164164

165165
// spec: ^1.13.6 => 1.13.7
166166
let match: im.IGoVersion | undefined = await im.findMatch('^1.13.6', true);
@@ -172,15 +172,15 @@ describe('setup-go', () => {
172172
});
173173

174174
it('finds latest version for major version spec', async () => {
175-
platSpy.mockImplementation(() => 'linux');
176-
archSpy.mockImplementation(() => 'amd64');
175+
platSpy.mockImplementation(() => 'windows');
176+
archSpy.mockImplementation(() => 'x32');
177177

178178
// spec: 1 => 1.13.7 (latest)
179179
let match: im.IGoVersion | undefined = await im.findMatch('1', true);
180180
expect(match).toBeDefined();
181181
let version: string = match ? match.version : '';
182182
expect(version).toBe('go1.13.7');
183183
let fileName = match ? match.files[0].filename : '';
184-
expect(fileName).toBe('go1.13.7.linux-amd64.tar.gz');
184+
expect(fileName).toBe('go1.13.7.windows-386.zip');
185185
});
186186
});

dist/index.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4506,15 +4506,8 @@ module.exports = bytesToUuid;
45064506

45074507
"use strict";
45084508

4509-
var __importStar = (this && this.__importStar) || function (mod) {
4510-
if (mod && mod.__esModule) return mod;
4511-
var result = {};
4512-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
4513-
result["default"] = mod;
4514-
return result;
4515-
};
45164509
Object.defineProperty(exports, "__esModule", { value: true });
4517-
const os = __importStar(__webpack_require__(87));
4510+
let os = __webpack_require__(87);
45184511
function getPlatform() {
45194512
// darwin and linux match already
45204513
// freebsd not supported yet but future proofed.
@@ -4536,9 +4529,9 @@ function getArch() {
45364529
case 'x64':
45374530
arch = 'amd64';
45384531
break;
4539-
case 'ppc':
4540-
arch = 'ppc64';
4541-
break;
4532+
// case 'ppc':
4533+
// arch = 'ppc64';
4534+
// break;
45424535
case 'x32':
45434536
arch = '386';
45444537
break;

src/system.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as os from 'os';
1+
let os = require('os');
22

33
export function getPlatform(): string {
44
// darwin and linux match already
@@ -25,9 +25,9 @@ export function getArch(): string {
2525
case 'x64':
2626
arch = 'amd64';
2727
break;
28-
case 'ppc':
29-
arch = 'ppc64';
30-
break;
28+
// case 'ppc':
29+
// arch = 'ppc64';
30+
// break;
3131
case 'x32':
3232
arch = '386';
3333
break;

0 commit comments

Comments
 (0)