Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

service-pool

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

service-pool - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

4

lib/ServicePool.js
'use strict'
const TypeDetect = require('type-detect')
const TypeDetect = require('agilite-utils/type-detect')
const EnumsTypeDetect = require('agilite-utils/enums-type-detect')
const Enums = require('./Enums')
const EnumsTypeDetect = require('./EnumsTypeDetect')

@@ -7,0 +7,0 @@ class ServicePool {

{
"name": "service-pool",
"license": "MIT",
"version": "1.0.1",
"version": "1.1.0",
"description": "A simple, lightweight, Resource Pool Manager for NodeJS",

@@ -36,4 +36,3 @@ "homepage": "https://agilite.io",

"dependencies": {
"dotenv": "8.2.0",
"type-detect": "4.0.8"
"agilite-utils": "7.1.0"
},

@@ -40,0 +39,0 @@ "devDependencies": {

'use strict'
require('dotenv').config()
const mongoose = require('mongoose')
const expect = require('chai').expect
const typeDetect = require('type-detect')
const TypeDetect = require('agilite-utils/type-detect')
const EnumsTypeDetect = require('agilite-utils/enums-type-detect')
const servicePool = require('../lib/ServicePool')
const enumsTypeDetect = require('../lib/EnumsTypeDetect')
const ServicePool = require('../lib/ServicePool')
let id1 = 'id111'
let id2 = 'id222'
let id3 = 'id333'
const id1 = 'id111'
const id2 = 'id222'
const id3 = 'id333'
const config = { max: 2 }
const pool = new servicePool(config)
const pool = new ServicePool(config)

@@ -62,3 +61,3 @@ const serviceEntry1 = {

describe ('Mongoose', () => {
describe('Mongoose', () => {
let service1 = null

@@ -68,15 +67,15 @@ let service2 = null

it ('Check Max Prop is valid', (done) => {
it('Check Max Prop is valid', (done) => {
expect(pool.getConfig()).to.haveOwnProperty('max')
expect(typeDetect(pool.getConfig().max)).to.equal(enumsTypeDetect.NUMBER)
expect(TypeDetect(pool.getConfig().max)).to.equal(EnumsTypeDetect.NUMBER)
done()
})
it ('Create First Pool Entry', (done) => {
service1 = pool.add(serviceEntry1)
expect(typeDetect(service1)).to.equal(enumsTypeDetect.PROMISE)
done()
it('Create First Pool Entry', (done) => {
service1 = pool.add(serviceEntry1)
expect(EnumsTypeDetect(service1)).to.equal(EnumsTypeDetect.PROMISE)
done()
})
it ('Test Connection is Active', (done) => {
it('Test Connection is Active', (done) => {
expect(pool.test(id1)).to.equal(true)

@@ -86,3 +85,3 @@ done()

it ('Check for 1 Active Service', (done) => {
it('Check for 1 Active Service', (done) => {
expect(pool.getActiveServiceCount()).to.equal(1)

@@ -92,3 +91,3 @@ done()

it ('Destroy Connection', (done) => {
it('Destroy Connection', (done) => {
expect(pool.destroy(id1)).to.equal(true)

@@ -98,3 +97,3 @@ done()

it ('Check for 0 Active Service', (done) => {
it('Check for 0 Active Service', (done) => {
expect(pool.getActiveServiceCount()).to.equal(0)

@@ -104,14 +103,14 @@ done()

it ('Create 3 Pool Entries', (done) => {
it('Create 3 Pool Entries', (done) => {
service1 = pool.add(serviceEntry1)
service2 = pool.add(serviceEntry2)
service3 = pool.add(serviceEntry3)
expect(typeDetect(service1)).to.equal(enumsTypeDetect.PROMISE)
expect(typeDetect(service2)).to.equal(enumsTypeDetect.PROMISE)
expect(typeDetect(service3)).to.equal(enumsTypeDetect.PROMISE)
expect(TypeDetect(service1)).to.equal(EnumsTypeDetect.PROMISE)
expect(TypeDetect(service2)).to.equal(EnumsTypeDetect.PROMISE)
expect(TypeDetect(service3)).to.equal(EnumsTypeDetect.PROMISE)
done()
})
it (`Check for ${config.max} Active Service`, (done) => {
it(`Check for ${config.max} Active Service`, (done) => {
expect(pool.getActiveServiceCount()).to.equal(config.max)

@@ -121,9 +120,9 @@ done()

it ('Add Duplicate Entry', (done) => {
it('Add Duplicate Entry', (done) => {
service2 = pool.add(serviceEntry22)
expect(typeDetect(service2)).to.equal(enumsTypeDetect.PROMISE)
expect(TypeDetect(service2)).to.equal(EnumsTypeDetect.PROMISE)
done()
})
it ('Destroy 2nd Connection', (done) => {
it('Destroy 2nd Connection', (done) => {
expect(pool.destroy(id3)).to.equal(true)

@@ -133,3 +132,3 @@ done()

it (`Check for ${config.max - 1} Active Service`, (done) => {
it(`Check for ${config.max - 1} Active Service`, (done) => {
expect(pool.getActiveServiceCount()).to.equal(config.max - 1)

@@ -139,3 +138,3 @@ done()

it ('Test 1st Service is Active', (done) => {
it('Test 1st Service is Active', (done) => {
expect(pool.test(id2)).to.equal(true)

@@ -145,8 +144,8 @@ done()

it ('Get 1st Service', (done) => {
expect(typeDetect(pool.get(id2))).to.equal(enumsTypeDetect.OBJECT)
it('Get 1st Service', (done) => {
expect(TypeDetect(pool.get(id2))).to.equal(EnumsTypeDetect.OBJECT)
done()
})
it ('Reset Services', (done) => {
it('Reset Services', (done) => {
expect(pool.reset()).to.equal(true)

@@ -156,6 +155,6 @@ done()

it ('Check for 0 Active Service', (done) => {
it('Check for 0 Active Service', (done) => {
expect(pool.getActiveServiceCount()).to.equal(0)
done()
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc