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

update test with node matrix #44

Closed
wants to merge 8 commits into from
Closed
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
14 changes: 8 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@ on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
branches: [ "main" ]

jobs:
test:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18, 20, 22]
steps:
- name: Checkout Source Tree
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
node-version: "${{ matrix.node-version }}"

- name: Install dependencies
run: npm install --include=dev

- name: Run tests
run: npm run test

- name: Publish dev package
run: npx pkg-pr-new publish
if: github.ref == 'refs/heads/main' && matrix.node-version == '22'
run: npx pkg-pr-new publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
tmp/
processed.txt
/.idea/
48 changes: 45 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "node --inspect=9229 demo/index.js"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"files": [
"src",
Expand Down Expand Up @@ -87,6 +87,7 @@
"pkg-pr-new": "^0.0.29",
"pug": "^3.0.3",
"response-time": "^2.3.2",
"form-data": "^4.0.1",
"serve-index": "^1.9.1",
"serve-static": "^1.16.2",
"swig": "^1.4.2",
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/middlewares/express-fileupload-temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const express = require("express");
const fileUpload = require("express-fileupload");
const fs = require("fs");
const FormData = require("form-data");

const app = express();

Expand All @@ -26,8 +27,7 @@ app.listen(13333, async () => {
arr[i] = i % 256;
}
console.log('appending file');
const file = new File(arr, 'test.txt');
formData.append('file', file);
formData.append('file', Buffer.from(arr), 'test.txt');

console.log('sending request');
const response = await fetch('http://localhost:13333/file', {
Expand Down
5 changes: 3 additions & 2 deletions tests/tests/middlewares/express-fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const express = require("express");
const fileUpload = require("express-fileupload");
const FormData = require("form-data");

const app = express();

Expand All @@ -13,8 +14,8 @@ app.listen(13333, async () => {
console.log('Server is running on port 13333');

const formData = new FormData();
const file = new File([1, 2, 3], 'test.txt');
formData.append('file', file);
const fileBuffer = Buffer.from([1, 2, 3]);
formData.append('file', fileBuffer, 'test.txt');

const response = await fetch('http://localhost:13333/file', {
method: 'POST',
Expand Down
5 changes: 3 additions & 2 deletions tests/tests/middlewares/multer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const express = require("express");
const multer = require("multer");
const FormData = require("form-data");

const app = express();
const upload = multer();
Expand All @@ -28,8 +29,8 @@ app.listen(13333, async () => {
console.log(text);

const formData2 = new FormData();
const file = new File([1, 2, 3], 'test.txt');
formData2.append('file', file);
const fileBuffer = Buffer.from([1, 2, 3]);
formData2.append('file', fileBuffer, 'test.txt');

const response2 = await fetch('http://localhost:13333/file', {
method: 'POST',
Expand Down
8 changes: 5 additions & 3 deletions tests/tests/middlewares/multiple-middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const express = require("express");
const bodyParser = require("body-parser");
const fileUpload = require("express-fileupload");
const FormData = require("form-data");

const app = express();

Expand All @@ -17,10 +18,11 @@ app.listen(13333, async () => {

const formData = new FormData();
console.log('creating file');
const arr = [...new Array(1024 * 32)].map((_, i) => i % 256); // 32 KB
const file = new File(arr, 'test.txt');
// Create a buffer for the file (32 KB of data)
const buffer = Buffer.from([...new Array(1024 * 32)].map((_, i) => i % 256));

console.log('appending file');
formData.append('file', file);
formData.append('file', buffer, 'test.txt');
formData.append('text', 'hello');
console.log('sending request');

Expand Down
Loading