Skip to content
Permalink
88dd91b7a5
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
60 lines (51 sloc) 1.49 KB
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