Skip to content

Commit

Permalink
Remove getManagerOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn committed Oct 29, 2024
1 parent 97e0902 commit 354a0a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
17 changes: 13 additions & 4 deletions src/server/test/test-helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { KeyManager } from '@mapeo/crypto'
import createFastify from 'fastify'
import { randomBytes } from 'node:crypto'
import { getManagerOptions } from '../../../test-e2e/utils.js'
import RAM from 'random-access-memory'
import comapeoServer from '../app.js'
/** @import { TestContext } from 'node:test' */
/** @import { ServerOptions } from '../app.js' */
Expand All @@ -19,9 +19,18 @@ const TEST_SERVER_DEFAULTS = {
* @returns {import('fastify').FastifyInstance & { deviceId: string }}
*/
export function createTestServer(t, serverOptions) {
const serverName =
serverOptions?.serverName || TEST_SERVER_DEFAULTS.serverName
const managerOptions = getManagerOptions(serverName)
const comapeoCoreUrl = new URL('../../..', import.meta.url)
const projectMigrationsFolder = new URL('./drizzle/project', comapeoCoreUrl)
.pathname
const clientMigrationsFolder = new URL('./drizzle/client', comapeoCoreUrl)
.pathname
const managerOptions = {
rootKey: randomBytes(16),
projectMigrationsFolder,
clientMigrationsFolder,
dbFolder: ':memory:',
coreStorage: () => new RAM(),
}
const km = new KeyManager(managerOptions.rootKey)
const server = createFastify()
server.register(comapeoServer, {
Expand Down
18 changes: 0 additions & 18 deletions test-e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,6 @@ export async function createManagers(
)
}

/**
* TODO: DRY this out with the below
* @param {string} seed
* @param {Partial<ConstructorParameters<typeof MapeoManager>[0]>} [overrides]
* @returns {ConstructorParameters<typeof MapeoManager>[0]}
*/
export function getManagerOptions(seed, overrides = {}) {
return {
rootKey: getRootKey(seed),
projectMigrationsFolder,
clientMigrationsFolder,
dbFolder: ':memory:',
coreStorage: () => new RAM(),
fastify: Fastify(),
...overrides,
}
}

/**
* @param {string} seed
* @param {import('node:test').TestContext} t
Expand Down

0 comments on commit 354a0a8

Please sign in to comment.