forked from docker/build-push-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: start sending get request with query params
We are incorrectly using formData in a get request. To move away from this we send both query params and formData until the server is fully upgraded. After which we can stop sending formData.
- Loading branch information
1 parent
50ccb6c
commit 4833ac8
Showing
4 changed files
with
78 additions
and
14 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as reporter from '../reporter'; | ||
import { getStickyDisk } from '../setup_builder'; | ||
|
||
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 () => { | ||
await getStickyDisk(); | ||
|
||
// Verify the get call was made | ||
expect(mockGet).toHaveBeenCalledTimes(1); | ||
|
||
// Get the arguments from the mock call | ||
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 | ||
expect(formData.get('stickyDiskKey')).toBe('test-repo'); | ||
expect(formData.get('region')).toBe('test-region'); | ||
expect(formData.get('installationModelID')).toBe('test-model'); | ||
expect(formData.get('vmID')).toBe('test-vm'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters