Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Harrison committed Jul 27, 2021
1 parent 423f9d9 commit f889f40
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 50 deletions.
46 changes: 0 additions & 46 deletions __tests__/fixtures/job-details/npm.json

This file was deleted.

5 changes: 4 additions & 1 deletion __tests__/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ export const removeDanglingUpdaterContainers = async (): Promise<void> => {
}

export const runFakeDependabotApi = async (port: number): Promise<Function> => {
const server = spawn(`${path.join(__dirname, 'server/server.js')}`, [
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 => {
Expand Down
11 changes: 8 additions & 3 deletions __tests__/server/server.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/usr/bin/env node

const jsonServer = require('json-server')
const path = require('path')
const fs = require('fs')
const server = jsonServer.create()
const db = JSON.parse(fs.readFileSync(path.join(__dirname, 'db.json')))
const router = jsonServer.router(db)
const middlewares = jsonServer.defaults()

const SERVER_PORT = process.argv.slice(2)[0] || 9000

// Sets up a fake dependabot-api using json-server
//
// Test it locally by running this script directly:
// $ node __tests__/server/server.js
// Running on http://localhost:9000
//
// Verify it works: curl http://localhost:9000/update_jobs/1/details

// NOTE: Serialise the response like dependabot-api
router.render = (_, res) => {
const id = res.locals.data.id
Expand Down

0 comments on commit f889f40

Please sign in to comment.