Skip to content

Commit

Permalink
Merge pull request #294 from Automattic/update/ci-github-actions
Browse files Browse the repository at this point in the history
Update tests and move to GitHub actions
  • Loading branch information
chriszarate authored Apr 13, 2022
2 parents 2e0953f + daf0be1 commit e292704
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 82 deletions.
59 changes: 0 additions & 59 deletions .circleci/config.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

name: Lint

on:
pull_request:
branches:
- trunk

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14, 16]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2.5.1
with:
cache: 'npm'
node-version: ${{ matrix.node-version }}

- name: Install
run: npm install

- name: Test
run: npm run lint
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

name: Test

on:
pull_request:
branches:
- trunk

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14, 16]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2.5.1
with:
cache: 'npm'
node-version: ${{ matrix.node-version }}

- name: Install
run: npm install

- name: Test
run: npm test
30 changes: 15 additions & 15 deletions __tests__/redis.tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const redis = require( '../src/redis/' );
const IORedis = require( 'ioredis' );
const Transport = require( 'winston-transport' );
const wait = require( 'waait' );

jest.mock( 'ioredis' );

class TestTransport extends Transport {
constructor( opts ) {
Expand All @@ -18,8 +20,6 @@ class TestTransport extends Transport {
}
}

const DEFAULT_REDIS_LOCAL_IP = '127.0.0.1:6379';

describe( 'src/redis', () => {
const OLD_ENV_VARS = process.env;

Expand Down Expand Up @@ -99,18 +99,18 @@ describe( 'src/redis', () => {

describe( 'Environment variable REDIS_MASTER is present', () => {
it( 'Should connect succesfully and return the redis client back', async () => {
process.env.REDIS_MASTER = DEFAULT_REDIS_LOCAL_IP;
const transport = new TestTransport();
const redisClient = redis( { logger: transport } );

expect( transport.logs[ 0 ] ).toMatch( 'Initializing a new redis client...' );

// Wait 5 ticks for the connection to redis server, triggering the connection listener and writing the logs
await wait( 5 );

expect( transport.logs[ 1 ] ).toMatch( 'Connected to Redis client...' );

redisClient.disconnect();
process.env.REDIS_MASTER = 'neverneverland:9876';
process.env.REDIS_PASSWORD = 'secret123';
redis();

expect( IORedis ).toHaveBeenCalledWith( {
enableOfflineQueue: true,
host: 'neverneverland',
maxRetriesPerRequest: 3,
password: 'secret123',
port: '9876',
retryStrategy: expect.any( Function ),
} );
} );
} );
} );
6 changes: 0 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
"ioredis": "4.14.1",
"jest": "25.1.0",
"publish-please": "5.5.1",
"supertest": "4.0.2",
"waait": "1.0.5"
"supertest": "4.0.2"
},
"dependencies": {
"winston": "^3.0.0"
Expand Down

0 comments on commit e292704

Please sign in to comment.