Skip to content

Commit

Permalink
replace travis with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshy committed Jul 12, 2024
1 parent 5e7ecd2 commit 300ae04
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 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@v3
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.

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 300ae04

Please sign in to comment.