|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -import {afterEach, describe, expect, test} from '@jest/globals'; |
| 17 | +import {afterEach, describe, expect, jest, test} from '@jest/globals'; |
18 | 18 | import fs from 'fs'; |
19 | 19 | import os from 'os'; |
20 | 20 | import path from 'path'; |
21 | 21 | import * as rimraf from 'rimraf'; |
| 22 | +import osm = require('os'); |
22 | 23 |
|
23 | 24 | import {OCI} from '../../src/oci/oci'; |
24 | 25 |
|
| 26 | +import {Platform} from '../../src/types/oci/descriptor'; |
| 27 | + |
25 | 28 | const fixturesDir = path.join(__dirname, '..', '.fixtures'); |
26 | 29 | const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'oci-oci-')); |
27 | 30 |
|
28 | 31 | afterEach(function () { |
29 | 32 | rimraf.sync(tmpDir); |
30 | 33 | }); |
31 | 34 |
|
| 35 | +describe('defaultPlatform', () => { |
| 36 | + test.each([ |
| 37 | + ['win32', 'x64', {architecture: 'amd64', os: 'windows'}], |
| 38 | + ['win32', 'arm64', {architecture: 'arm64', os: 'windows'}], |
| 39 | + ['darwin', 'x64', {architecture: 'amd64', os: 'darwin'}], |
| 40 | + ['darwin', 'arm64', {architecture: 'arm64', os: 'darwin'}], |
| 41 | + ['linux', 'ia32', {architecture: '386', os: 'linux'}], |
| 42 | + ['linux', 'x64', {architecture: 'amd64', os: 'linux'}], |
| 43 | + ['linux', 'arm64', {architecture: 'arm64', os: 'linux'}], |
| 44 | + ['linux', 'ppc64', {architecture: 'ppc64le', os: 'linux'}], |
| 45 | + ['linux', 's390x', {architecture: 's390x', os: 'linux'}] |
| 46 | + ])('default platform for %s/%s', async (os: string, arch: string, expected: Platform) => { |
| 47 | + jest.spyOn(osm, 'platform').mockImplementation(() => os as NodeJS.Platform); |
| 48 | + jest.spyOn(osm, 'arch').mockImplementation(() => arch); |
| 49 | + const res = OCI.defaultPlatform(); |
| 50 | + expect(res).toEqual(expected); |
| 51 | + }); |
| 52 | +}); |
| 53 | + |
32 | 54 | describe('loadArchive', () => { |
33 | 55 | // prettier-ignore |
34 | 56 | test.each(fs.readdirSync(path.join(fixturesDir, 'oci-archive')).filter(file => { |
|
0 commit comments