From 2828d20fa743b94c034d639b6a9fd104e38f2c69 Mon Sep 17 00:00:00 2001 From: alice-was-here <82787803+alice-was-here@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:33:49 +0800 Subject: [PATCH] CI fixes --- package.json | 4 ++-- test/openS3_v3.js | 48 ++++++++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 47aedc9..73a62e7 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "iconv-lite": "^0.4.24", "request": "^2.88.0", "stream-buffers": ">= 0.2.5 < 1", - "tap": "^12.7.0", + "tap": "^16.3.10", "temp": ">= 0.4.0 < 1" }, "peerDependencies": { @@ -60,6 +60,6 @@ ], "main": "unzip.js", "scripts": { - "test": "npx tap test/*.js --coverage-report=html --reporter=dot" + "test": "npx tap@^16.3.10 test/*.js --no-coverage --reporter=dot" } } diff --git a/test/openS3_v3.js b/test/openS3_v3.js index 6cb720b..378bf0d 100644 --- a/test/openS3_v3.js +++ b/test/openS3_v3.js @@ -1,25 +1,35 @@ -const test = require('tap').test; -const fs = require('fs'); -const path = require('path'); -const unzip = require('../unzip'); +const test = require("tap").test; +const unzip = require("../unzip"); -const version = +process.version.replace('v', '').split('.')[0]; +const version = +process.version.replace("v", "").split(".")[0]; -test("get content of a single file entry out of a zip", { skip: version < 16 }, function(t) { - const { S3Client } = require('@aws-sdk/client-s3'); - const client = new S3Client({ region: 'us-east-1' }); +test( + "get content of a single file entry out of a zip", + { skip: version < 16 }, + function (t) { + const { S3Client } = require("@aws-sdk/client-s3"); - return unzip.Open.s3_v3(client, { Bucket: 'unzipper', Key: 'archive.zip' }) - .then(function(d) { - const file = d.files.filter(function(file) { - return file.path == 'file.txt'; + const client = new S3Client({ + region: "us-east-1", + signer: { sign: async (request) => request }, + }); + + // These files are provided by AWS's open data registry project. + // https://github.com/awslabs/open-data-registry + + return unzip.Open.s3_v3(client, { + Bucket: "wikisum", + Key: "WikiSumDataset.zip", + }).then(function (d) { + const file = d.files.filter(function (file) { + return file.path == "WikiSumDataset/LICENSE.txt"; })[0]; - return file.buffer() - .then(function(str) { - const fileStr = fs.readFileSync(path.join(__dirname, '../testData/compressed-standard/inflated/file.txt'), 'utf8'); - t.equal(str.toString(), fileStr); - t.end(); - }); + return file.buffer().then(function (b) { + const firstLine = b.toString().split("\n")[0]; + t.equal(firstLine, "Attribution-NonCommercial-ShareAlike 3.0 Unported"); + t.end(); + }); }); -}); + } +);