Skip to content

Commit

Permalink
Test redis on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Butz committed Dec 10, 2019
1 parent 97149a0 commit 04bca47
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ cache:
mocha:
script:
- npm install
- npm test
- REDIS_HOST=redis npm test
28 changes: 28 additions & 0 deletions services/cache.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const redis = require("redis");
const assert = require("assert");
const redisHost = process.env.REDIS_HOST || 'localhost';
const promisify = require("util").promisify;

describe('our cache', () => {
let redisClient;

beforeEach(() => {
redisClient = redis.createClient({host: redisHost});
});

afterEach(() => {
redisClient.quit();
});

it('stores stuff', async () => {
const flushall = promisify(redisClient.flushall).bind(redisClient);
const dbsize = promisify(redisClient.dbsize).bind(redisClient);
const set = promisify(redisClient.set).bind(redisClient);
const get = promisify(redisClient.get).bind(redisClient);

await flushall();
assert.equal(await dbsize(), 0);
await set('foo', 1234);
assert.equal(await get('foo'), 1234);
});
});
4 changes: 2 additions & 2 deletions services/nasa.client.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');

describe('foo', () => {
describe('a working test', () => {
it('works', () => {
assert.equal(true, false);
assert.equal(true, true);
});
});

0 comments on commit 04bca47

Please sign in to comment.