Skip to content

Commit

Permalink
chore: cleanup (#325)
Browse files Browse the repository at this point in the history
* chore: cleanup

* chore: increase timeout to 30s
  • Loading branch information
danez authored Mar 7, 2023
1 parent 0ee2e1d commit 331717d
Show file tree
Hide file tree
Showing 13 changed files with 2,163 additions and 2,542 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
'max-statements': 'off',
'node/no-missing-import': 'off',
'no-shadow': 'off',
'no-use-before-define': 'off',
'unicorn/prefer-json-parse-buffer': 'off',
},
overrides: [
Expand Down
8 changes: 4 additions & 4 deletions node/bridge.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Buffer } from 'buffer'
import fs from 'fs'
import { rm } from 'fs/promises'
import { createRequire } from 'module'
import { platform, env } from 'process'
import { PassThrough } from 'stream'
Expand Down Expand Up @@ -68,7 +68,7 @@ test('Does not inherit environment variables if `extendEnv` is false', async ()

expect(output).toBe('LULU=LALA')

await fs.promises.rmdir(tmpDir.path, { recursive: true })
await rm(tmpDir.path, { force: true, recursive: true })
})

test('Does inherit environment variables if `extendEnv` is true', async () => {
Expand Down Expand Up @@ -101,7 +101,7 @@ test('Does inherit environment variables if `extendEnv` is true', async () => {

expect(environmentVariables).toEqual(['LULU=LALA', 'TADA=TUDU'])

await fs.promises.rmdir(tmpDir.path, { recursive: true })
await rm(tmpDir.path, { force: true, recursive: true })
})

test('Does inherit environment variables if `extendEnv` is not set', async () => {
Expand Down Expand Up @@ -134,5 +134,5 @@ test('Does inherit environment variables if `extendEnv` is not set', async () =>

expect(environmentVariables).toEqual(['LULU=LALA', 'TADA=TUDU'])

await fs.promises.rmdir(tmpDir.path, { recursive: true })
await rm(tmpDir.path, { force: true, recursive: true })
})
2 changes: 0 additions & 2 deletions node/deploy_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import type { Layer } from './layer.js'
import type { Logger } from './logger.js'
import { isFileNotFoundError } from './utils/error.js'

/* eslint-disable camelcase */
interface DeployConfigFile {
functions?: Declaration[]
import_map?: string
layers?: Layer[]
version: number
}
/* eslint-enable camelcase */

export interface DeployConfig {
declarations: Declaration[]
Expand Down
4 changes: 2 additions & 2 deletions node/downloader.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { promises as fs } from 'fs'
import { rm } from 'fs/promises'
import { platform } from 'process'
import { PassThrough } from 'stream'

Expand Down Expand Up @@ -32,7 +32,7 @@ beforeEach(async (ctx: TestContext) => {
})

afterEach(async (ctx: TestContext) => {
await fs.rmdir(ctx.tmpDir, { recursive: true })
await rm(ctx.tmpDir, { force: true, recursive: true })
})

test('tries downloading binary up to 4 times', async (ctx: TestContext) => {
Expand Down
4 changes: 2 additions & 2 deletions node/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Buffer } from 'buffer'
import fs from 'fs'
import { rm } from 'fs/promises'
import { createRequire } from 'module'
import { platform } from 'process'
import { PassThrough } from 'stream'
Expand Down Expand Up @@ -51,5 +51,5 @@ test('Downloads the Deno CLI on demand and caches it for subsequent calls', asyn
expect(beforeDownload).toHaveBeenCalledTimes(1)
expect(afterDownload).toHaveBeenCalledTimes(1)

await fs.promises.rmdir(tmpDir.path, { recursive: true })
await rm(tmpDir.path, { force: true, recursive: true })
})
3 changes: 0 additions & 3 deletions node/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Layer } from './layer.js'
import { getPackageVersion } from './package_json.js'
import { nonNullable } from './utils/non_nullable.js'

/* eslint-disable camelcase */
interface Route {
function: string
name?: string
Expand All @@ -32,8 +31,6 @@ interface Manifest {
function_config: Record<string, EdgeFunctionConfig>
}

/* eslint-enable camelcase */

interface GenerateManifestOptions {
bundles?: Bundle[]
declarations?: Declaration[]
Expand Down
12 changes: 6 additions & 6 deletions node/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { promises as fs } from 'fs'
import { readFile, rm, writeFile } from 'fs/promises'
import { join } from 'path'

import nock from 'nock'
Expand Down Expand Up @@ -26,7 +26,7 @@ test('`ensureLatestTypes` updates the Deno CLI cache if the local version of typ

await ensureLatestTypes(deno, testLogger, mockURL)

const versionFile = await fs.readFile(join(tmpDir.path, 'types-version.txt'), 'utf8')
const versionFile = await readFile(join(tmpDir.path, 'types-version.txt'), 'utf8')

expect(latestVersionMock.isDone()).toBe(true)
expect(mock).toHaveBeenCalledTimes(1)
Expand All @@ -35,7 +35,7 @@ test('`ensureLatestTypes` updates the Deno CLI cache if the local version of typ

mock.mockRestore()

await fs.rmdir(tmpDir.path, { recursive: true })
await rm(tmpDir.path, { force: true, recursive: true })
})

test('`ensureLatestTypes` does not update the Deno CLI cache if the local version of types is up-to-date', async () => {
Expand All @@ -45,7 +45,7 @@ test('`ensureLatestTypes` does not update the Deno CLI cache if the local versio
const tmpDir = await tmp.dir()
const versionFilePath = join(tmpDir.path, 'types-version.txt')

await fs.writeFile(versionFilePath, mockVersion)
await writeFile(versionFilePath, mockVersion)

const latestVersionMock = nock(mockURL).get('/version.txt').reply(200, mockVersion)
const deno = new DenoBridge({
Expand All @@ -63,7 +63,7 @@ test('`ensureLatestTypes` does not update the Deno CLI cache if the local versio

mock.mockRestore()

await fs.rmdir(tmpDir.path, { recursive: true })
await rm(tmpDir.path, { force: true, recursive: true })
})

test('`ensureLatestTypes` does not throw if the types URL is not available', async () => {
Expand All @@ -86,5 +86,5 @@ test('`ensureLatestTypes` does not throw if the types URL is not available', asy

mock.mockRestore()

await fs.rmdir(tmpDir.path, { recursive: true })
await rm(tmpDir.path, { force: true, recursive: true })
})
5 changes: 5 additions & 0 deletions node/validation/manifest/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import chalk from 'chalk'
import { test, expect, describe } from 'vitest'

import { validateManifest, ManifestValidationError } from './index.js'

// We need to disable all color outputs for the tests as they are different on different platforms, CI, etc.
// This only works if this is the same instance of chalk that better-ajv-errors uses
chalk.level = 0

// Factory so we have a new object per test
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const getBaseManifest = (): Record<string, any> => ({
Expand Down
2 changes: 1 addition & 1 deletion node/validation/manifest/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Ajv from 'ajv'
import ajvErrors from 'ajv-errors'
import type { ValidateFunction } from 'ajv/dist/core.js'
import ajvErrors from 'ajv-errors'
import betterAjvErrors from 'better-ajv-errors'

import type { Manifest } from '../../manifest.js'
Expand Down
Loading

0 comments on commit 331717d

Please sign in to comment.