Skip to content

Commit 7043a9c

Browse files
authored
test: add a test case for compress file into Buffer (#104)
closes #103 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Removed the `workflow_dispatch` trigger from Node.js workflow configurations. - **Tests** - Added a new test for gzip compression functionality. - Reorganized test scripts in `package.json` for better clarity and execution. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1112123 commit 7043a9c

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

.github/workflows/nodejs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ on:
77
pull_request:
88
branches: [ master ]
99

10-
workflow_dispatch: {}
11-
1210
jobs:
1311
Job:
1412
name: Node.js

.github/workflows/release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@ on:
44
push:
55
branches: [ master ]
66

7-
workflow_dispatch: {}
8-
97
jobs:
108
release:
119
name: Node.js
1210
uses: node-modules/github-actions/.github/workflows/node-release.yml@master
1311
secrets:
1412
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1513
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
16-
with:
17-
checkTest: false

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"main": "index.js",
66
"scripts": {
77
"contributor": "git-contributor",
8-
"ts-test": "tsc -p ./test/fixtures/types/tsconfig.json",
9-
"test": "egg-bin test --ts false && npm run ts-test",
8+
"test:ts": "tsc -p ./test/fixtures/types/tsconfig.json",
9+
"test:js": "egg-bin test --ts false",
10+
"test": "npm run test:js && npm run test:ts",
1011
"cov": "egg-bin cov --ts false",
1112
"lint-fix": "eslint . --fix",
1213
"lint": "eslint .",
13-
"ci": "npm run lint && npm run ts-test && npm run cov"
14+
"ci": "npm run lint && npm run test:ts && npm run cov"
1415
},
1516
"repository": {
1617
"type": "git",

test/gzip/file_stream.test.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const fs = require('fs');
42
const os = require('os');
53
const path = require('path');
@@ -36,6 +34,19 @@ describe('test/gzip/file_stream.test.js', () => {
3634
});
3735
});
3836

37+
it('should compress file into Buffer', async () => {
38+
const sourceFile = path.join(__dirname, '..', 'fixtures', 'xx.log');
39+
const gzipStream = new compressing.gzip.FileStream({ source: sourceFile });
40+
const gzipChunks = [];
41+
for await (const chunk of gzipStream) {
42+
gzipChunks.push(chunk);
43+
}
44+
45+
const destFile = path.join(os.tmpdir(), uuid.v4() + '.log.gz');
46+
await fs.promises.writeFile(destFile, Buffer.concat(gzipChunks));
47+
console.log(destFile);
48+
});
49+
3950
it('should compress buffer', done => {
4051
const sourceFile = path.join(__dirname, '..', 'fixtures', 'xx.log');
4152
const sourceBuffer = fs.readFileSync(sourceFile);

0 commit comments

Comments
 (0)