Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigaStrgar committed Nov 30, 2020
0 parents commit 9655758
Show file tree
Hide file tree
Showing 27 changed files with 7,128 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"env": {
"es2020": true,
"jest/globals": true,
"node": true
},
"extends": [
"standard"
],
"parserOptions": {
"ecmaVersion": 2020
},
"plugins": [
"jest"
],
"rules": {
"indent": [
"warn",
4
],
"linebreak-style": [
"warn",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"warn",
"always"
],
"prefer-template": 2,
"no-useless-concat": 2,
"no-unused-vars": 2,
"no-undef": 2,
"no-var": 2
}
}
68 changes: 68 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# Mac Finder thumbnail store
.DS_Store

temp

.idea
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: node_js
node_js:
- 14
- 15
install:
- yarn
services:
- redis-server
script:
- yarn lint
- yarn coverage
notifications:
email:
on_success: never
8 changes: 8 additions & 0 deletions docs/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##### Description 🖋
<!--- Briefly describe your changes -->

##### Types of changes 🌈
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
35 changes: 35 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# BlubBlub Node Queue

Repository contains the queue service with endpoints to manage the queue.

## Installation

This project only contains NPM dependencies, to install them use the following command.

```shell script
yarn install
```

## Testing & Linting

### Linting

Project have predefined ESLint configuration file with style and static code analysis setup.

```shell script
yarn lint
```

### Testing

To run the tests simpy use the command below.

```shell script
yarn test
```

Or in case if you want to also generate coverage report.

```shell script
yarn coverage
```
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const consumer = require('./lib/consumer');
const endpoints = require('./lib/endpoints');
const service = require('./lib/service');

module.exports = {
Consumer: consumer,
Router: endpoints,
Service: service
};
45 changes: 45 additions & 0 deletions lib/__tests__/consumer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const consumer = require('../consumer');
const service = require('../service');

const utils = require('../../test/utils');

jest.mock('ioredis');

beforeEach(async () => {
await utils.setupQueues([{
name: 'queue'
}, {
name: 'default',
defaultJobOptions: {
test: 'test'
}
}]);
});

afterEach(async () => {
await utils.cleanUpAndDisconnect(service);
});

describe('Queue Consumer', () => {
test('Process defaults', async () => {
consumer(service, {});

expect(await service.getQueue('default').getWorkers()).toHaveLength(1);
});

test('Concurrency', async () => {
await utils.setupQueues([{
name: 'multiworker',
metadata: {
processNumber: 3
}
}]);

jest.spyOn(service.getQueue('multiworker'), 'process');

consumer(service, {});

expect(service.getQueue('multiworker').process).toBeCalledTimes(1);
expect(service.getQueue('multiworker').process).toBeCalledWith('*', 3, expect.any(Function));
});
});
Loading

0 comments on commit 9655758

Please sign in to comment.