mirror of
https://github.com/docker/setup-buildx-action.git
synced 2025-04-22 16:06:36 +02:00
Add config-inline
input
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
ee7ac3140a
commit
34e94a5fed
13 changed files with 4751 additions and 16 deletions
|
@ -6,6 +6,8 @@ import * as context from '../src/context';
|
|||
import * as semver from 'semver';
|
||||
import * as exec from '@actions/exec';
|
||||
|
||||
const tmpNameSync = path.join('/tmp/.docker-setup-buildx-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||
|
||||
jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
||||
const tmpDir = path.join('/tmp/.docker-setup-buildx-jest').split(path.sep).join(path.posix.sep);
|
||||
if (!fs.existsSync(tmpDir)) {
|
||||
|
@ -14,6 +16,10 @@ jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
|||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
|
||||
return tmpNameSync;
|
||||
});
|
||||
|
||||
describe('isAvailable', () => {
|
||||
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
|
||||
buildx.isAvailable();
|
||||
|
@ -119,3 +125,37 @@ describe('install', () => {
|
|||
expect(fs.existsSync(buildxBin)).toBe(true);
|
||||
}, 100000);
|
||||
});
|
||||
|
||||
describe('getConfig', () => {
|
||||
test.each([
|
||||
['debug = true', false, 'debug = true', false],
|
||||
[`notfound.toml`, true, '', true],
|
||||
[
|
||||
`${path.join(__dirname, 'fixtures', 'buildkitd.toml').split(path.sep).join(path.posix.sep)}`,
|
||||
true,
|
||||
`debug = true
|
||||
[registry."docker.io"]
|
||||
mirrors = ["mirror.gcr.io"]
|
||||
`,
|
||||
false
|
||||
]
|
||||
])('given %p config', async (val, file, exValue, invalid) => {
|
||||
try {
|
||||
let config: string;
|
||||
if (file) {
|
||||
config = await buildx.getConfigFile(val);
|
||||
} else {
|
||||
config = await buildx.getConfigInline(val);
|
||||
}
|
||||
expect(true).toBe(!invalid);
|
||||
console.log(`config: ${config}`);
|
||||
expect(config).toEqual(`${tmpNameSync}`);
|
||||
const configValue = await fs.readFileSync(tmpNameSync, 'utf-8');
|
||||
console.log(`configValue: ${configValue}`);
|
||||
expect(configValue).toEqual(exValue);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
expect(true).toBe(invalid);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,6 +11,10 @@ jest.spyOn(context, 'tmpDir').mockImplementation((): string => {
|
|||
return tmpDir;
|
||||
});
|
||||
|
||||
jest.spyOn(context, 'tmpNameSync').mockImplementation((): string => {
|
||||
return path.join('/tmp/.docker-setup-buildx-jest', '.tmpname-jest').split(path.sep).join(path.posix.sep);
|
||||
});
|
||||
|
||||
describe('getInputList', () => {
|
||||
it('handles single line correctly', async () => {
|
||||
await setInput('foo', 'bar');
|
||||
|
|
3
__tests__/fixtures/buildkitd.toml
Normal file
3
__tests__/fixtures/buildkitd.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
debug = true
|
||||
[registry."docker.io"]
|
||||
mirrors = ["mirror.gcr.io"]
|
Loading…
Add table
Add a link
Reference in a new issue