mirror of
https://github.com/docker/build-push-action.git
synced 2026-02-19 16:06:38 +00:00
The test was hardcoded to expect arm64 platform, causing failures on AMD runners. Now checks actual host architecture dynamically. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import * as os from 'os';
|
|
import {getRemoteBuilderArgs, resolveRemoteBuilderPlatforms} from '../context';
|
|
|
|
jest.mock('@actions/core', () => ({
|
|
info: jest.fn(),
|
|
debug: jest.fn(),
|
|
warning: jest.fn(),
|
|
error: jest.fn()
|
|
}));
|
|
|
|
describe('Remote builder platform argument resolution', () => {
|
|
const builderName = 'test-builder';
|
|
const builderUrl = 'tcp://127.0.0.1:1234';
|
|
|
|
afterEach(() => {
|
|
jest.restoreAllMocks();
|
|
});
|
|
|
|
test('returns comma-separated list when platforms are supplied', async () => {
|
|
const platforms = ['linux/arm64', 'linux/amd64'];
|
|
const platformStr = resolveRemoteBuilderPlatforms(platforms);
|
|
expect(platformStr).toBe('linux/arm64,linux/amd64');
|
|
|
|
const args = await getRemoteBuilderArgs(builderName, builderUrl, platforms);
|
|
const idx = args.indexOf('--platform');
|
|
expect(idx).toBeGreaterThan(-1);
|
|
expect(args[idx + 1]).toBe('linux/arm64,linux/amd64');
|
|
});
|
|
|
|
test('falls back to host architecture when no platforms supplied', async () => {
|
|
const platformStr = resolveRemoteBuilderPlatforms([]);
|
|
const expectedPlatform = os.arch() === 'arm64' ? 'linux/arm64' : 'linux/amd64';
|
|
expect(platformStr).toBe(expectedPlatform);
|
|
|
|
const args = await getRemoteBuilderArgs(builderName, builderUrl, []);
|
|
const idx = args.indexOf('--platform');
|
|
expect(idx).toBeGreaterThan(-1);
|
|
expect(args[idx + 1]).toBe(expectedPlatform);
|
|
});
|
|
});
|