Skip to content

Commit

Permalink
set authSource when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed Nov 16, 2021
1 parent e4575e7 commit ea1a7f3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/single-instance/single-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ const { test } = require('uvu')
const expect = require('expect')
const Mongoose = require('mongoose')

const { MONGODB_USERNAME, MONGODB_PASSWORD, MONGODB_DB } = process.env

test('connects to MongoDB', async () => {
const connection = await Mongoose.createConnection('mongodb://localhost', {
user: process.env.MONGODB_USERNAME,
pass: process.env.MONGODB_PASSWORD,
dbName: process.env.MONGODB_DB,
authSource: 'admin'
user: MONGODB_USERNAME,
pass: MONGODB_PASSWORD,
dbName: MONGODB_DB,
authSource: MONGODB_USERNAME && MONGODB_PASSWORD ? 'admin' : undefined
}).asPromise()

await connection.close()
Expand Down

0 comments on commit ea1a7f3

Please sign in to comment.