Skip to content

Commit

Permalink
Merge pull request #70 from jameshy/ci
Browse files Browse the repository at this point in the history
Create node.js.yml
  • Loading branch information
jameshy authored Jul 12, 2024
2 parents 5e7ecd2 + f8a1160 commit 8421ed8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pgdump-aws-lambda

[![Build Status](https://travis-ci.org/jameshy/pgdump-aws-lambda.svg?branch=master)](https://travis-ci.org/jameshy/pgdump-aws-lambda)
![ci status](https://github.com/github/docs/actions/workflows/node.js.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/jameshy/pgdump-aws-lambda/badge.svg?branch=master)](https://coveralls.io/github/jameshy/pgdump-aws-lambda?branch=master)

An AWS Lambda function that runs pg_dump and streams the output to s3.
Expand Down
18 changes: 9 additions & 9 deletions test/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ describe('Handler', () => {
expect(stream).to.be.ok
expect(config.S3_BUCKET).to.equal(mockEvent.S3_BUCKET)
expect(config.PGDATABASE).to.equal(mockEvent.PGDATABASE)
expect(key).to.equal('2017-05-02/dbname-02-05-2017@01-33-11.backup')
expect(key).to.equal('2017-05-02/dbname-02-05-2017_01-33-11.backup')
expect(result).to.equal(
'mock-uploaded/2017-05-02/dbname-02-05-2017@01-33-11.backup'
'mock-uploaded/2017-05-02/dbname-02-05-2017_01-33-11.backup'
)
})

Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Handler', () => {
expect(stream).to.be.ok
expect(config.S3_BUCKET).to.equal(mockEvent.S3_BUCKET)
expect(config.PGDATABASE).to.equal('dbone')
expect(key).to.equal('2017-05-02/dbone-02-05-2017@01-33-11.backup')
expect(key).to.equal('2017-05-02/dbone-02-05-2017_01-33-11.backup')
}
{
// second call
Expand All @@ -116,13 +116,13 @@ describe('Handler', () => {
expect(stream).to.be.ok
expect(config.S3_BUCKET).to.equal(mockEvent.S3_BUCKET)
expect(config.PGDATABASE).to.equal('dbtwo')
expect(key).to.equal('2017-05-02/dbtwo-02-05-2017@01-33-11.backup')
expect(key).to.equal('2017-05-02/dbtwo-02-05-2017_01-33-11.backup')
}

// result should be an array with two backup paths
expect(result).deep.to.equal([
'mock-uploaded/2017-05-02/dbone-02-05-2017@01-33-11.backup',
'mock-uploaded/2017-05-02/dbtwo-02-05-2017@01-33-11.backup'
'mock-uploaded/2017-05-02/dbone-02-05-2017_01-33-11.backup',
'mock-uploaded/2017-05-02/dbtwo-02-05-2017_01-33-11.backup'
])
})

Expand Down Expand Up @@ -193,18 +193,18 @@ describe('Handler', () => {
expect(config.PGDATABASE).to.equal(mockEvent.PGDATABASE)
expect(key).to.be.a.string
expect(key).to.not.be.empty
expect(key).to.equal('2017-05-02/dbname-02-05-2017@01-33-11.backup.iv')
expect(key).to.equal('2017-05-02/dbname-02-05-2017_01-33-11.backup.iv')

// second call is the backup
const [stream2, config2, key2] = s3Spy.secondCall.args
expect(stream2).to.be.ok
expect(config2.S3_BUCKET).to.equal(mockEvent.S3_BUCKET)
expect(config2.PGDATABASE).to.equal(mockEvent.PGDATABASE)
expect(key2).to.equal('2017-05-02/dbname-02-05-2017@01-33-11.backup')
expect(key2).to.equal('2017-05-02/dbname-02-05-2017_01-33-11.backup')

// handler should return the backup path
expect(result).to.equal(
'mock-uploaded/2017-05-02/dbname-02-05-2017@01-33-11.backup'
'mock-uploaded/2017-05-02/dbname-02-05-2017_01-33-11.backup'
)
})

Expand Down
2 changes: 1 addition & 1 deletion test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Utils', () => {
it('should generate a correct path', () => {
const databaseName = 'test-db'
const now = moment('2017-04-22 15:01:02')
const expected = '2017-04-22/test-db-22-04-2017@15-01-02.backup'
const expected = '2017-04-22/test-db-22-04-2017_15-01-02.backup'
const result = utils.generateBackupPath(databaseName, null, now)
expect(result).to.equal(expected)
})
Expand Down

0 comments on commit 8421ed8

Please sign in to comment.