text: 
  const server = require('../../../test-utils/index')
  const chai = require('chai')
  const expect = chai.expect
  chai.use(require('chai-http'))
  const CveIdRange = require('../../../src/model/cve-id-range')
  const CveId = require('../../../src/model/cve-id')
  const User = require('../../../src/model/user')
  const Org = require('../../../src/model/org')
  const CONSTANTS = require('../../../src/constants')
  const availableCveIds = require('./mockObjects.non-sequential').availableCveIds
  const userAHeader = require('./mockObjects.non-sequential').userAHeader
  const orgA = require('./mockObjects.non-sequential').orgA
  const userA = require('./mockObjects.non-sequential').userA
  const year = require('./mockObjects.non-sequential').year
  const ids = []
  let reserved
  
  describe('Test ID Reservator for Non-Sequential Case A', () => {
    before(async () => {
      // Create a Cve Id Range for year 2030
      const defaultDoc = CONSTANTS.DEFAULT_CVE_ID_RANGE
      defaultDoc.cve_year = year
      defaultDoc.ranges.general.top_id = 20005
      defaultDoc.ranges.general.end = 30000
  
      await CveIdRange.findOneAndUpdate()
        .byCveYear(defaultDoc.cve_year)
        .updateOne(defaultDoc)
        .setOptions({ upsert: true })
  
      // Create org A
      await Org.findOneAndUpdate()
        .byUUID(orgA.UUID)
        .updateOne(orgA)
        .setOptions({ upsert: true })
  
      // Create user A
      await User.findOneAndUpdate()
        .byUUID(userA.UUID)
        .updateOne(userA)
        .setOptions({ upsert: true })
  
      // Create 5 available CVE IDs
      await CveId.insertMany(availableCveIds)
    })
  
    context('Case A', () => {
      it('Pool is incremented, reservation fails, pool is updated, and 10 ids are reserved', (done) => {
        // perform the request to the api
        chai.request(server)
          .post(`/api/test/cve-id/case/A?batch_type=non-sequential&short_name=${orgA.short_name}&cve_year=${year}&amount=10`)
          .set(userAHeader)
          .end((err, res) => {
            if (err) {
              done(err)
            }
  
            // checking header
            const quotaHeader = (orgA.policies.id_quota - 10).toString()
            expect(res.header).to.have.property('cve-api-remaining-quota').and.to.equal(quotaHeader)
  
            // assert expected response
            expect(res).to.have.status(200)
            expect(res).to.have.property('body').and.to.be.a('object')
            expect(res.body).to.have.property('cve_ids').and.to.be.a('array')
            res.body.cve_ids.forEach(obj => {
              ids.push(obj.cve_id)
              const index = parseInt(obj.cve_id.match(/\d+$/g))
              expect(index).to.be.greaterThan(20000).and.lessThan(20111) // Available id range: CVE-YYYY-20001 to CVE-YYYY-20110
              expect(obj).to.have.property('state').and.to.equal('RESERVED') // checking that all CVE IDs returned are RESERVED
              expect(obj).to.have.property('owning_cna').and.to.equal(orgA.short_name)
              expect(obj).to.have.nested.property('requested_by.cna').and.to.equal(orgA.short_name)
              expect(obj).to.have.nested.property('requested_by.user').and.to.equal(userA.username)
            })
  
            done()
          })
      })
  
      it('Check count of reserved ids by userA in the db', async () => {
        // checking that the correct amount of RESERVED ids were created
        const reservedCount = await CveId.countDocuments({ owning_cna: orgA.UUID, cve_year: year, state: 'RESERVED' })
        expect(reservedCount).to.equal(10) // end - start + 1
      })
  
      it('Check count of available ids in the db', async () => {
        // checking that the correct amount of AVAILABLE ids were created
        const availableCount = await CveId.countDocuments({ cve_year: year, state: 'AVAILABLE' })
        expect(availableCount).to.equal(100) // increment - reserved + initial = 105 - 10 + 5 = 100
      })
  
      it('Check that reserved ids by userA are reserved in the db', async () => {
        // checking that all CVE IDs returned are RESERVED
        reserved = await CveId.find({ cve_id: { $in: ids }, cve_year: year }) // cve ids reserved by userA
        reserved.forEach(obj => {
          expect(obj).to.have.property('state').and.to.equal('RESERVED')
          expect(obj).to.have.property('owning_cna').and.to.equal(orgA.UUID)
          expect(obj).to.have.nested.property('requested_by.cna').and.to.equal(userA.org_UUID)
          expect(obj).to.have.nested.property('requested_by.user').and.to.equal(userA.UUID)
        })
      })
  
      it('Check that there are no duplicates in the reserved ids', (done) => {
        // checking that there are no duplicates
        reserved.forEach(id1 => {
          let counter = 0
  
          reserved.forEach(id2 => {
            if (id1 === id2) {
              counter++
            }
          })
  
          expect(counter).to.equal(1)
        })
  
        done()
      })
  
      it('Check that unreserved ids by userA are available in the db', async () => {
        const topId = (await CveIdRange.findOneAndUpdate({ cve_year: year })).ranges.general.top_id // get top_id
        // checking that all CVE IDs not returned are AVAILABLE
        const available = await CveId.find({ cve_id: { $nin: ids }, cve_year: year }) // cve ids not reserved
        available.forEach(obj => {
          const index = parseInt(obj.cve_id.match(/\d+$/g))
          expect(index).to.be.lessThan(topId + 1) // check that the id is less than the current top id
          expect(obj).to.have.property('state').and.to.equal('AVAILABLE')
          expect(obj).to.have.property('owning_cna').and.to.equal('N/A')
          expect(obj).to.have.nested.property('requested_by.cna').and.to.equal('N/A')
          expect(obj).to.have.nested.property('requested_by.user').and.to.equal('N/A')
        })
      })
    })
  
    after(async () => {
      await CveId.deleteMany({})
      await CveIdRange.deleteMany({})
      await User.deleteMany({})
      await Org.deleteMany({})
    })
  })
  