chore(integration): throw errors on catch blocks (#2091)
Why: Suppressing errors and not failing the execution will lead to misleading errors of the following tests. Fixes CORE-461
This commit is contained in:
+16
-20
@@ -5,30 +5,26 @@ const importFrom = require("import-from")
|
||||
|
||||
module.exports = {
|
||||
bootstrapApp: async ({ cwd } = {}) => {
|
||||
try {
|
||||
const app = express()
|
||||
const app = express()
|
||||
|
||||
const loaders = importFrom(
|
||||
cwd || process.cwd(),
|
||||
"@medusajs/medusa/dist/loaders"
|
||||
).default
|
||||
const loaders = importFrom(
|
||||
cwd || process.cwd(),
|
||||
"@medusajs/medusa/dist/loaders"
|
||||
).default
|
||||
|
||||
const { container, dbConnection } = await loaders({
|
||||
directory: path.resolve(cwd || process.cwd()),
|
||||
expressApp: app,
|
||||
isTest: false,
|
||||
})
|
||||
const { container, dbConnection } = await loaders({
|
||||
directory: path.resolve(cwd || process.cwd()),
|
||||
expressApp: app,
|
||||
isTest: false,
|
||||
})
|
||||
|
||||
const PORT = await getPort()
|
||||
const PORT = await getPort()
|
||||
|
||||
return {
|
||||
container,
|
||||
db: dbConnection,
|
||||
app,
|
||||
port: PORT,
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
return {
|
||||
container,
|
||||
db: dbConnection,
|
||||
app,
|
||||
port: PORT,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -24,65 +24,60 @@ class DatabaseFactory {
|
||||
}
|
||||
|
||||
async createTemplateDb_({ cwd }) {
|
||||
try {
|
||||
// const cwd = path.resolve(path.join(__dirname, ".."))
|
||||
const connection = await this.getMasterConnection()
|
||||
const migrationDir = path.resolve(
|
||||
path.join(
|
||||
cwd,
|
||||
`node_modules`,
|
||||
`@medusajs`,
|
||||
`medusa`,
|
||||
`dist`,
|
||||
`migrations`,
|
||||
`*.js`
|
||||
)
|
||||
)
|
||||
|
||||
const { getEnabledMigrations } = require(path.join(
|
||||
// const cwd = path.resolve(path.join(__dirname, ".."))
|
||||
const connection = await this.getMasterConnection()
|
||||
const migrationDir = path.resolve(
|
||||
path.join(
|
||||
cwd,
|
||||
`node_modules`,
|
||||
`@medusajs`,
|
||||
`medusa`,
|
||||
`dist`,
|
||||
`commands`,
|
||||
`utils`,
|
||||
`get-migrations`
|
||||
))
|
||||
|
||||
// filter migrations to only include those that dont have feature flags
|
||||
const enabledMigrations = await getEnabledMigrations(
|
||||
[migrationDir],
|
||||
(flag) => false
|
||||
`migrations`,
|
||||
`*.js`
|
||||
)
|
||||
)
|
||||
|
||||
await dropDatabase(
|
||||
{
|
||||
databaseName: this.templateDbName,
|
||||
errorIfNonExist: false,
|
||||
},
|
||||
pgGodCredentials
|
||||
)
|
||||
await createDatabase(
|
||||
{ databaseName: this.templateDbName },
|
||||
pgGodCredentials
|
||||
)
|
||||
const { getEnabledMigrations } = require(path.join(
|
||||
cwd,
|
||||
`node_modules`,
|
||||
`@medusajs`,
|
||||
`medusa`,
|
||||
`dist`,
|
||||
`commands`,
|
||||
`utils`,
|
||||
`get-migrations`
|
||||
))
|
||||
|
||||
const templateDbConnection = await createConnection({
|
||||
type: "postgres",
|
||||
name: "templateConnection",
|
||||
url: `${DB_URL}/${this.templateDbName}`,
|
||||
migrations: enabledMigrations,
|
||||
})
|
||||
// filter migrations to only include those that dont have feature flags
|
||||
const enabledMigrations = await getEnabledMigrations(
|
||||
[migrationDir],
|
||||
(flag) => false
|
||||
)
|
||||
|
||||
await templateDbConnection.runMigrations()
|
||||
await templateDbConnection.close()
|
||||
await dropDatabase(
|
||||
{
|
||||
databaseName: this.templateDbName,
|
||||
errorIfNonExist: false,
|
||||
},
|
||||
pgGodCredentials
|
||||
)
|
||||
await createDatabase(
|
||||
{ databaseName: this.templateDbName },
|
||||
pgGodCredentials
|
||||
)
|
||||
|
||||
return connection
|
||||
} catch (err) {
|
||||
console.log("error in createTemplateDb_")
|
||||
console.log(err)
|
||||
}
|
||||
const templateDbConnection = await createConnection({
|
||||
type: "postgres",
|
||||
name: "templateConnection",
|
||||
url: `${DB_URL}/${this.templateDbName}`,
|
||||
migrations: enabledMigrations,
|
||||
})
|
||||
|
||||
await templateDbConnection.runMigrations()
|
||||
await templateDbConnection.close()
|
||||
|
||||
return connection
|
||||
}
|
||||
|
||||
async getMasterConnection() {
|
||||
|
||||
Reference in New Issue
Block a user