diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..476854c --- /dev/null +++ b/.github/workflows/node.js.yml @@ -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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4c7c681..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: node_js -node_js: - - '12.14.0' -after_success: npm run coveralls diff --git a/test/handler.js b/test/handler.js index a119a49..60eae3c 100644 --- a/test/handler.js +++ b/test/handler.js @@ -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' ) }) @@ -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 @@ -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' ]) }) @@ -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' ) }) diff --git a/test/utils.js b/test/utils.js index 549ef73..a60d3cd 100644 --- a/test/utils.js +++ b/test/utils.js @@ -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) })