1
0
Fork 0
mirror of https://github.com/docker/build-push-action.git synced 2025-05-08 06:29:30 +02:00

*: move to grpc backed communication for the agent

This commit is contained in:
Aditya Maru 2024-12-16 15:09:23 -05:00
parent c7c50538d0
commit d43ee61bb7
10 changed files with 144 additions and 128 deletions

View file

@ -1,54 +0,0 @@
import * as reporter from '../reporter';
import { getStickyDisk } from '../setup_builder';
import FormData from 'form-data';
jest.mock('../reporter');
describe('getStickyDisk', () => {
const mockGet = jest.fn();
beforeEach(() => {
jest.resetAllMocks();
process.env.GITHUB_REPO_NAME = 'test-repo';
process.env.BLACKSMITH_REGION = 'test-region';
process.env.BLACKSMITH_INSTALLATION_MODEL_ID = 'test-model';
process.env.VM_ID = 'test-vm';
(reporter.createBlacksmithAgentClient as jest.Mock).mockResolvedValue({});
(reporter.get as jest.Mock).mockImplementation(mockGet);
mockGet.mockResolvedValue({
data: {
expose_id: 'test-expose-id',
disk_identifier: 'test-device'
}
});
});
it('sets both FormData and query parameters correctly', async () => {
const appendSpy = jest.spyOn(FormData.prototype, 'append');
await getStickyDisk();
expect(mockGet).toHaveBeenCalledTimes(1);
const [, url, formData] = mockGet.mock.calls[0];
// Verify query parameters
expect(url).toContain('stickyDiskKey=test-repo');
expect(url).toContain('region=test-region');
expect(url).toContain('installationModelID=test-model');
expect(url).toContain('vmID=test-vm');
// Verify FormData is correct type
expect(formData instanceof FormData).toBeTruthy();
// Verify the headers are set correctly
const headers = formData.getHeaders();
expect(headers['content-type']).toContain('multipart/form-data');
// Verify the correct fields were appended
expect(appendSpy).toHaveBeenCalledWith('stickyDiskKey', 'test-repo');
expect(appendSpy).toHaveBeenCalledWith('region', 'test-region');
expect(appendSpy).toHaveBeenCalledWith('installationModelID', 'test-model');
expect(appendSpy).toHaveBeenCalledWith('vmID', 'test-vm');
});
});