2020-08-18 11:40:31 -04:00
|
|
|
import fs = require('fs');
|
2020-08-26 19:48:38 -04:00
|
|
|
import * as docker from '../src/docker';
|
2020-08-18 11:40:31 -04:00
|
|
|
import * as buildx from '../src/buildx';
|
|
|
|
import * as path from 'path';
|
|
|
|
import * as os from 'os';
|
|
|
|
|
|
|
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-'));
|
|
|
|
|
|
|
|
describe('buildx', () => {
|
2020-08-26 19:48:38 -04:00
|
|
|
async function isDaemonRunning() {
|
|
|
|
return await docker.isDaemonRunning();
|
|
|
|
}
|
|
|
|
|
2020-08-18 11:40:31 -04:00
|
|
|
it('is available', async () => {
|
|
|
|
expect(await buildx.isAvailable()).toBe(true);
|
|
|
|
}, 100000);
|
|
|
|
|
|
|
|
it('count builders', async () => {
|
|
|
|
const countBuilders = await buildx.countBuilders();
|
|
|
|
console.log(`countBuilders: ${countBuilders}`);
|
|
|
|
expect(countBuilders).toBeGreaterThan(0);
|
|
|
|
}, 100000);
|
|
|
|
|
2020-08-26 19:48:38 -04:00
|
|
|
(isDaemonRunning() ? it : it.skip)(
|
|
|
|
'platforms',
|
|
|
|
async () => {
|
|
|
|
const platforms = buildx.platforms();
|
|
|
|
console.log(`platforms: ${platforms}`);
|
|
|
|
expect(platforms).not.toBeUndefined();
|
|
|
|
expect(platforms).not.toEqual('');
|
|
|
|
},
|
|
|
|
100000
|
|
|
|
);
|
2020-08-18 11:40:31 -04:00
|
|
|
|
|
|
|
it('acquires v0.2.2 version of buildx', async () => {
|
|
|
|
const buildxBin = await buildx.install('v0.2.2', tmpDir);
|
|
|
|
console.log(buildxBin);
|
|
|
|
expect(fs.existsSync(buildxBin)).toBe(true);
|
|
|
|
}, 100000);
|
|
|
|
|
|
|
|
it('acquires latest version of buildx', async () => {
|
|
|
|
const buildxBin = await buildx.install('latest', tmpDir);
|
|
|
|
console.log(buildxBin);
|
|
|
|
expect(fs.existsSync(buildxBin)).toBe(true);
|
|
|
|
}, 100000);
|
|
|
|
});
|