test: passing text field suite (#5341)

This commit is contained in:
Patrik
2024-03-15 14:27:43 -04:00
committed by GitHub
parent aaf17aa2b2
commit c5f9533d2b
10 changed files with 49 additions and 26 deletions

View File

@@ -1,3 +1,5 @@
import type { MongooseAdapter } from 'packages/db-mongodb/src/index.js'
import fs from 'fs'
import path from 'path'
@@ -9,12 +11,12 @@ import { createSnapshot, dbSnapshot, restoreFromSnapshot } from './snapshot.js'
type SeedFunction = (_payload: Payload) => Promise<void>
export async function seedDB({
shouldResetDB,
_payload,
snapshotKey,
seedFunction,
uploadsDir,
collectionSlugs,
seedFunction,
shouldResetDB,
snapshotKey,
uploadsDir,
}: {
_payload: Payload
collectionSlugs: string[]
@@ -71,9 +73,10 @@ export async function seedDB({
// Dropping the db breaks indexes (on mongoose - did not test extensively on postgres yet), so we recreate them here
if (shouldResetDB) {
if (isMongoose(_payload)) {
const db = _payload.db as MongooseAdapter
await Promise.all([
...collectionSlugs.map(async (collectionSlug) => {
await _payload.db.collections[collectionSlug].createIndexes()
Object.entries(db.collections).map(async ([_, collection]) => {
await collection.createIndexes()
}),
])
}