Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add a test case for compress file into Buffer #104

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
pull_request:
branches: [ master ]

workflow_dispatch: {}

jobs:
Job:
name: Node.js
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ on:
push:
branches: [ master ]

workflow_dispatch: {}

jobs:
release:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-release.yml@master
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
checkTest: false
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"main": "index.js",
"scripts": {
"contributor": "git-contributor",
"ts-test": "tsc -p ./test/fixtures/types/tsconfig.json",
"test": "egg-bin test --ts false && npm run ts-test",
"test:ts": "tsc -p ./test/fixtures/types/tsconfig.json",
"test:js": "egg-bin test --ts false",
"test": "npm run test:js && npm run test:ts",
"cov": "egg-bin cov --ts false",
"lint-fix": "eslint . --fix",
"lint": "eslint .",
"ci": "npm run lint && npm run ts-test && npm run cov"
"ci": "npm run lint && npm run test:ts && npm run cov"
},
"repository": {
"type": "git",
Expand Down
15 changes: 13 additions & 2 deletions test/gzip/file_stream.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const fs = require('fs');
const os = require('os');
const path = require('path');
Expand Down Expand Up @@ -36,6 +34,19 @@ describe('test/gzip/file_stream.test.js', () => {
});
});

it('should compress file into Buffer', async () => {
const sourceFile = path.join(__dirname, '..', 'fixtures', 'xx.log');
const gzipStream = new compressing.gzip.FileStream({ source: sourceFile });
const gzipChunks = [];
for await (const chunk of gzipStream) {
gzipChunks.push(chunk);
}

const destFile = path.join(os.tmpdir(), uuid.v4() + '.log.gz');
await fs.promises.writeFile(destFile, Buffer.concat(gzipChunks));
console.log(destFile);
});

it('should compress buffer', done => {
const sourceFile = path.join(__dirname, '..', 'fixtures', 'xx.log');
const sourceBuffer = fs.readFileSync(sourceFile);
Expand Down
Loading