Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
dependabot-action/__tests__/helpers.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
60 lines (51 sloc)
1.49 KB
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
import Docker from 'dockerode' | |
import {UPDATER_IMAGE_NAME, PROXY_IMAGE_NAME} from '../src/docker-tags' | |
import waitPort from 'wait-port' | |
import path from 'path' | |
import {spawn} from 'child_process' | |
export const removeDanglingUpdaterContainers = async (): Promise<void> => { | |
const docker = new Docker() | |
const containers = (await docker.listContainers()) || [] | |
for (const container of containers) { | |
if ( | |
container.Image.includes(UPDATER_IMAGE_NAME) || | |
container.Image.includes(PROXY_IMAGE_NAME) | |
) { | |
try { | |
await docker.getContainer(container.Id).remove({v: true, force: true}) | |
} catch (e) { | |
// ignore | |
} | |
} | |
} | |
await docker.pruneNetworks() | |
await docker.pruneContainers() | |
} | |
export const runFakeDependabotApi = async (port = 9000): Promise<Function> => { | |
const server = spawn('node', [ | |
`${path.join(__dirname, 'server/server.js')}`, | |
`${port}` | |
]) | |
server.stdout.on('data', (data: any) => { | |
console.log(`json-server log: ${data}`) // eslint-disable-line no-console | |
}) | |
server.stderr.on('data', (data: any) => { | |
console.error(`json-server error: ${data}`) // eslint-disable-line no-console | |
}) | |
await waitPort({port}) | |
return (): void => { | |
server.kill() | |
} | |
} | |
export const eventFixturePath = (fixtureName: string): string => { | |
return path.join( | |
__dirname, | |
'..', | |
'__fixtures__', | |
'events', | |
`${fixtureName}.json` | |
) | |
} | |
export const integration = process.env.SKIP_INTEGRATION_TESTS | |
? describe.skip | |
: describe |