fix(offer): Added entity biz logic and unit tests for offer status

This commit is contained in:
Chris Troutner
2022-03-21 11:39:23 -07:00
parent dcaa73a22f
commit 1563a740aa
10 changed files with 137 additions and 19 deletions
+37
View File
@@ -0,0 +1,37 @@
/*
This script has not been customized for offers yet.
*/
const mongoose = require('mongoose')
// Force test environment
// make sure environment variable is set before this file gets called.
// see test script in package.json.
// process.env.KOA_ENV = 'test'
const config = require('../../config')
const User = require('../../src/models/users')
async function deleteUsers () {
// Connect to the Mongo Database.
mongoose.Promise = global.Promise
mongoose.set('useCreateIndex', true) // Stop deprecation warning.
await mongoose.connect(config.database, {
useUnifiedTopology: true,
useNewUrlParser: true
})
// Get all the users in the DB.
const users = await User.find({}, '-password')
// console.log(`users: ${JSON.stringify(users, null, 2)}`)
// Delete each user.
for (let i = 0; i < users.length; i++) {
const thisUser = users[i]
await thisUser.remove()
}
mongoose.connection.close()
}
deleteUsers()
+25
View File
@@ -0,0 +1,25 @@
/*
Get all Offers in the database.
*/
const mongoose = require('mongoose')
const config = require('../../config')
const Offer = require('../../src/adapters/localdb/models/offer')
async function getOffers () {
// Connect to the Mongo Database.
mongoose.Promise = global.Promise
mongoose.set('useCreateIndex', true) // Stop deprecation warning.
await mongoose.connect(config.database, {
useNewUrlParser: true,
useUnifiedTopology: true
})
const offers = await Offer.find({})
console.log(`offers: ${JSON.stringify(offers, null, 2)}`)
mongoose.connection.close()
}
getOffers()