|
1 | | -import fs = require('fs'); |
2 | | -import * as buildx from '../src/buildx'; |
3 | | -import * as path from 'path'; |
| 1 | +import * as fs from 'fs'; |
4 | 2 | import * as os from 'os'; |
| 3 | +import * as path from 'path'; |
| 4 | +import * as buildx from '../src/buildx'; |
| 5 | +import * as context from '../src/context'; |
5 | 6 | import * as semver from 'semver'; |
6 | 7 | import * as exec from '@actions/exec'; |
7 | 8 |
|
| 9 | +jest.spyOn(context, 'tmpDir').mockImplementation((): string => { |
| 10 | + const tmpDir = path.join('/tmp/.docker-setup-buildx-jest').split(path.sep).join(path.posix.sep); |
| 11 | + if (!fs.existsSync(tmpDir)) { |
| 12 | + fs.mkdirSync(tmpDir, {recursive: true}); |
| 13 | + } |
| 14 | + return tmpDir; |
| 15 | +}); |
| 16 | + |
8 | 17 | describe('isAvailable', () => { |
9 | 18 | const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput'); |
10 | 19 | buildx.isAvailable(); |
@@ -41,9 +50,20 @@ describe('parseVersion', () => { |
41 | 50 | test.each([ |
42 | 51 | ['github.com/docker/buildx 0.4.1+azure bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'], |
43 | 52 | ['github.com/docker/buildx v0.4.1 bda4882a65349ca359216b135896bddc1d92461c', '0.4.1'], |
44 | | - ['github.com/docker/buildx v0.4.2 fb7b670b764764dc4716df3eba07ffdae4cc47b2', '0.4.2'] |
| 53 | + ['github.com/docker/buildx v0.4.2 fb7b670b764764dc4716df3eba07ffdae4cc47b2', '0.4.2'], |
| 54 | + ['github.com/docker/buildx f117971 f11797113e5a9b86bd976329c5dbb8a8bfdfadfa', 'f117971'] |
45 | 55 | ])('given %p', async (stdout, expected) => { |
46 | | - expect(await buildx.parseVersion(stdout)).toEqual(expected); |
| 56 | + expect(buildx.parseVersion(stdout)).toEqual(expected); |
| 57 | + }); |
| 58 | +}); |
| 59 | + |
| 60 | +describe('satisfies', () => { |
| 61 | + test.each([ |
| 62 | + ['0.4.1', '>=0.3.2', true], |
| 63 | + ['bda4882a65349ca359216b135896bddc1d92461c', '>0.1.0', false], |
| 64 | + ['f117971', '>0.6.0', true] |
| 65 | + ])('given %p', async (version, range, expected) => { |
| 66 | + expect(buildx.satisfies(version, range)).toBe(expected); |
47 | 67 | }); |
48 | 68 | }); |
49 | 69 |
|
@@ -72,6 +92,15 @@ describe('inspect', () => { |
72 | 92 | ); |
73 | 93 | }); |
74 | 94 |
|
| 95 | +describe('build', () => { |
| 96 | + it.skip('valid', async () => { |
| 97 | + const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-')); |
| 98 | + const buildxBin = await buildx.build('https://github.com/docker/buildx.git#refs/pull/648/head', tmpDir); |
| 99 | + console.log(buildxBin); |
| 100 | + expect(fs.existsSync(buildxBin)).toBe(true); |
| 101 | + }, 100000); |
| 102 | +}); |
| 103 | + |
75 | 104 | describe('install', () => { |
76 | 105 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-buildx-')); |
77 | 106 | it('acquires v0.4.1 version of buildx', async () => { |
|
0 commit comments