Skip to content

Commit c73f6b0

Browse files
committed
More test cleanup
1 parent 943fa5a commit c73f6b0

File tree

6 files changed

+76
-86
lines changed

6 files changed

+76
-86
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ jobs:
2222
call-build-and-publish:
2323
name: CI
2424
uses: qlever-llc/workflows/.github/workflows/build-and-publish-package.yml@master
25+
secrets:
26+
# This is just a dev token, not actually secret
27+
oada_token: abc
2528
with:
2629
oada: true

lib/client.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ export class OADAClient {
653653
}
654654

655655
// TODO: should this error?
656-
if (Buffer.isBuffer(body)) {
656+
if (Buffer.isBuffer(body) || !body) {
657657
return body;
658658
}
659659

@@ -672,16 +672,12 @@ export class OADAClient {
672672
} else {
673673
// Otherwise, get children from the tree provided by the user
674674
for (const key of Object.keys(subTree ?? {})) {
675-
if (typeof body![key as keyof typeof body] === 'object') {
675+
if (typeof body[key as keyof typeof body] === 'object') {
676676
children.push({ treeKey: key, dataKey: key });
677677
}
678678
}
679679
}
680680

681-
if (!body) {
682-
return body;
683-
}
684-
685681
// Await recursive calls
686682
await Promise.all(
687683
children.map(async (item) => {

lib/http.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Buffer } from 'buffer';
2020
import { AbortController, Method } from 'fetch-h2';
2121
import EventEmitter from 'eventemitter3';
2222
import PQueue from 'p-queue';
23+
import type { Response } from 'fetch-h2';
2324
import debug from 'debug';
2425
import ksuid from 'ksuid';
2526
import typeIs from 'type-is';
@@ -51,6 +52,12 @@ function getIsomorphicContext() {
5152
return context ? context() : { fetch };
5253
}
5354

55+
async function getBody(result: Response): Promise<Body> {
56+
return typeIs.is(result.headers.get('content-type')!, ['json', '+json'])
57+
? ((await result.json()) as Json)
58+
: Buffer.from(await result.arrayBuffer());
59+
}
60+
5461
export class HttpClient extends EventEmitter implements Connection {
5562
#domain: string;
5663
#token;
@@ -225,13 +232,10 @@ export class HttpClient extends EventEmitter implements Connection {
225232
// Have to construct the headers as a regular object
226233
const headers = Object.fromEntries(result.headers.entries());
227234

228-
// Const length = +(result.headers.get("content-length") || 0);
229-
let data: Body | undefined;
230-
if (request.method.toUpperCase() !== 'HEAD') {
231-
data = typeIs.is(result.headers.get('content-type')!, ['json', '+json'])
232-
? ((await result.json()) as Json)
233-
: Buffer.from(await result.arrayBuffer());
234-
}
235+
const data: Body | undefined =
236+
request.method.toUpperCase() === 'HEAD'
237+
? undefined
238+
: await getBody(result);
235239

236240
// Trace("length = %d, result.headers = %O", length, headers);
237241
return [

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@
102102
"@types/type-is": "^1.6.3",
103103
"@types/uuid": "^8.3.4",
104104
"@types/ws": "^8.5.3",
105-
"@typescript-eslint/eslint-plugin": "^5.15.0",
106-
"@typescript-eslint/parser": "^5.15.0",
105+
"@typescript-eslint/eslint-plugin": "^5.16.0",
106+
"@typescript-eslint/parser": "^5.16.0",
107107
"@yarnpkg/sdks": "2.6.0",
108108
"ava": "4.0.0-rc.1",
109109
"axios": "^0.26.1",
@@ -119,7 +119,7 @@
119119
"eslint-plugin-ava": "^13.2.0",
120120
"eslint-plugin-eslint-comments": "^3.2.0",
121121
"eslint-plugin-filenames": "^1.3.2",
122-
"eslint-plugin-github": "^4.3.5",
122+
"eslint-plugin-github": "^4.3.6",
123123
"eslint-plugin-i18n-text": "^1.0.1",
124124
"eslint-plugin-import": "^2.25.4",
125125
"eslint-plugin-no-constructor-bind": "^2.0.4",

test/watch.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ for (const connection of <const>['ws', 'http']) {
5454
let client: OADAClient;
5555

5656
// Initialization
57+
// eslint-disable-next-line ava/hooks-order
5758
test.before(`${connection}: Initialize connection`, async () => {
5859
// Connect
5960
client = await connect({
@@ -64,6 +65,7 @@ for (const connection of <const>['ws', 'http']) {
6465
});
6566

6667
// Cleanup
68+
// eslint-disable-next-line ava/hooks-order
6769
test.after(`${connection}: Destroy connection`, async () => {
6870
// Disconnect
6971
await client?.disconnect();

yarn.lock

Lines changed: 55 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ __metadata:
181181
"@types/type-is": ^1.6.3
182182
"@types/uuid": ^8.3.4
183183
"@types/ws": ^8.5.3
184-
"@typescript-eslint/eslint-plugin": ^5.15.0
185-
"@typescript-eslint/parser": ^5.15.0
184+
"@typescript-eslint/eslint-plugin": ^5.16.0
185+
"@typescript-eslint/parser": ^5.16.0
186186
"@yarnpkg/sdks": 2.6.0
187187
abort-controller: ^3.0.0
188188
ava: 4.0.0-rc.1
@@ -205,7 +205,7 @@ __metadata:
205205
eslint-plugin-ava: ^13.2.0
206206
eslint-plugin-eslint-comments: ^3.2.0
207207
eslint-plugin-filenames: ^1.3.2
208-
eslint-plugin-github: ^4.3.5
208+
eslint-plugin-github: ^4.3.6
209209
eslint-plugin-i18n-text: ^1.0.1
210210
eslint-plugin-import: ^2.25.4
211211
eslint-plugin-no-constructor-bind: ^2.0.4
@@ -460,13 +460,13 @@ __metadata:
460460
languageName: node
461461
linkType: hard
462462

463-
"@typescript-eslint/eslint-plugin@npm:^5.1.0, @typescript-eslint/eslint-plugin@npm:^5.15.0":
464-
version: 5.15.0
465-
resolution: "@typescript-eslint/eslint-plugin@npm:5.15.0"
463+
"@typescript-eslint/eslint-plugin@npm:^5.1.0, @typescript-eslint/eslint-plugin@npm:^5.16.0":
464+
version: 5.16.0
465+
resolution: "@typescript-eslint/eslint-plugin@npm:5.16.0"
466466
dependencies:
467-
"@typescript-eslint/scope-manager": 5.15.0
468-
"@typescript-eslint/type-utils": 5.15.0
469-
"@typescript-eslint/utils": 5.15.0
467+
"@typescript-eslint/scope-manager": 5.16.0
468+
"@typescript-eslint/type-utils": 5.16.0
469+
"@typescript-eslint/utils": 5.16.0
470470
debug: ^4.3.2
471471
functional-red-black-tree: ^1.0.1
472472
ignore: ^5.1.8
@@ -479,66 +479,66 @@ __metadata:
479479
peerDependenciesMeta:
480480
typescript:
481481
optional: true
482-
checksum: 730ec621b5d87a22ea53cb2a67cae15fd241ccec9cff1bc3bdd24622feb11ea39b186544b845c730afa22112d8922008f17d9116a06b1e2dcd975429209a0c0c
482+
checksum: 4007cc1599503424037300e7401fb969ca441b122ef8a8f2fc8d70f84d656fdf7ab7b0d00e506a3aaf702871616c3756da17eb1508ff315dfb25170f2d28a904
483483
languageName: node
484484
linkType: hard
485485

486-
"@typescript-eslint/parser@npm:^5.1.0, @typescript-eslint/parser@npm:^5.15.0":
487-
version: 5.15.0
488-
resolution: "@typescript-eslint/parser@npm:5.15.0"
486+
"@typescript-eslint/parser@npm:^5.1.0, @typescript-eslint/parser@npm:^5.16.0":
487+
version: 5.16.0
488+
resolution: "@typescript-eslint/parser@npm:5.16.0"
489489
dependencies:
490-
"@typescript-eslint/scope-manager": 5.15.0
491-
"@typescript-eslint/types": 5.15.0
492-
"@typescript-eslint/typescript-estree": 5.15.0
490+
"@typescript-eslint/scope-manager": 5.16.0
491+
"@typescript-eslint/types": 5.16.0
492+
"@typescript-eslint/typescript-estree": 5.16.0
493493
debug: ^4.3.2
494494
peerDependencies:
495495
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
496496
peerDependenciesMeta:
497497
typescript:
498498
optional: true
499-
checksum: 6b3047236349680e3a408aedf7490d304ad14d3f3264190eb058a472caeec07f85e8f298e6e774fd91cb001c9fd65a5fa558a9906afd30744bc05d8764cec250
499+
checksum: 40006578e9ac451c80dc4b4b7e29af97b53fb9e9ea660d6ca17fb98b5c9858c648f9b17523c9de9b9b9e4155af17b65435e6163f02c4a2dfacf48274f45cba21
500500
languageName: node
501501
linkType: hard
502502

503-
"@typescript-eslint/scope-manager@npm:5.15.0":
504-
version: 5.15.0
505-
resolution: "@typescript-eslint/scope-manager@npm:5.15.0"
503+
"@typescript-eslint/scope-manager@npm:5.16.0":
504+
version: 5.16.0
505+
resolution: "@typescript-eslint/scope-manager@npm:5.16.0"
506506
dependencies:
507-
"@typescript-eslint/types": 5.15.0
508-
"@typescript-eslint/visitor-keys": 5.15.0
509-
checksum: 39fa688691c5cc207d44cc1f5a3ba0ecb3c34144505b32c1267df9e9368cc29373acd7e85e27d6fe84a0012417e40745887baeec6719f33b8a5ae4232d0db061
507+
"@typescript-eslint/types": 5.16.0
508+
"@typescript-eslint/visitor-keys": 5.16.0
509+
checksum: 008a6607d3e6ebcc59a9b28cddcc25703f39a88e27a96c69a6d988acc50a1ea7dbf50963c165ffa5b85a101209a0da3a7ec6832633a162ca4ecc78c0e54acd9f
510510
languageName: node
511511
linkType: hard
512512

513-
"@typescript-eslint/type-utils@npm:5.15.0":
514-
version: 5.15.0
515-
resolution: "@typescript-eslint/type-utils@npm:5.15.0"
513+
"@typescript-eslint/type-utils@npm:5.16.0":
514+
version: 5.16.0
515+
resolution: "@typescript-eslint/type-utils@npm:5.16.0"
516516
dependencies:
517-
"@typescript-eslint/utils": 5.15.0
517+
"@typescript-eslint/utils": 5.16.0
518518
debug: ^4.3.2
519519
tsutils: ^3.21.0
520520
peerDependencies:
521521
eslint: "*"
522522
peerDependenciesMeta:
523523
typescript:
524524
optional: true
525-
checksum: ecefdec695602b04f5d403c741336c56a8aa4f5fa3cc48a202a7b3f548d4d470f44cec5632a3db819fe1ca27c9980dbd3100b8c93e4fd7e9a3fa4253c03f4c04
525+
checksum: 86d9f1dff6a096c8465453b8c7d0cc667b87a769f19073bfa9bbd36f8baa772c0384ec396b1132052383846bbbcf0d051345ed7d373260c1b506ed27100b383d
526526
languageName: node
527527
linkType: hard
528528

529-
"@typescript-eslint/types@npm:5.15.0":
530-
version: 5.15.0
531-
resolution: "@typescript-eslint/types@npm:5.15.0"
532-
checksum: 749d6eb366cb103924b51bcbe69d1c0fd6f7a00f5be4c01b3d6de3134537db956653db9958cdd8cc32f375bca818ea804f8e07697122943faff06232519529a1
529+
"@typescript-eslint/types@npm:5.16.0":
530+
version: 5.16.0
531+
resolution: "@typescript-eslint/types@npm:5.16.0"
532+
checksum: 0450125741c3eef9581da0b75b4a987a633d77009cfb03507c3db29885b790ee80e3c0efc4f9a0dd3376ba758b49c7829722676153472616a57bb04bce5cc4fa
533533
languageName: node
534534
linkType: hard
535535

536-
"@typescript-eslint/typescript-estree@npm:5.15.0":
537-
version: 5.15.0
538-
resolution: "@typescript-eslint/typescript-estree@npm:5.15.0"
536+
"@typescript-eslint/typescript-estree@npm:5.16.0":
537+
version: 5.16.0
538+
resolution: "@typescript-eslint/typescript-estree@npm:5.16.0"
539539
dependencies:
540-
"@typescript-eslint/types": 5.15.0
541-
"@typescript-eslint/visitor-keys": 5.15.0
540+
"@typescript-eslint/types": 5.16.0
541+
"@typescript-eslint/visitor-keys": 5.16.0
542542
debug: ^4.3.2
543543
globby: ^11.0.4
544544
is-glob: ^4.0.3
@@ -547,33 +547,33 @@ __metadata:
547547
peerDependenciesMeta:
548548
typescript:
549549
optional: true
550-
checksum: 84fbb5030db5c1ac34527860725a9ea5b104fa1c49072a69306954b4b8516242427e70cb6a657ec2b822789432179a0df7a866e4618a29ee54b4285ca23556c8
550+
checksum: 930ead4655712c3bd40885fb6b2074cd3c10fb03da864dd7a7dd2e43abfd330bb07e505f0aec8b4846178bff8befbb017f9f3370c67e9c717e4cb8d3df6e16ef
551551
languageName: node
552552
linkType: hard
553553

554-
"@typescript-eslint/utils@npm:5.15.0":
555-
version: 5.15.0
556-
resolution: "@typescript-eslint/utils@npm:5.15.0"
554+
"@typescript-eslint/utils@npm:5.16.0":
555+
version: 5.16.0
556+
resolution: "@typescript-eslint/utils@npm:5.16.0"
557557
dependencies:
558558
"@types/json-schema": ^7.0.9
559-
"@typescript-eslint/scope-manager": 5.15.0
560-
"@typescript-eslint/types": 5.15.0
561-
"@typescript-eslint/typescript-estree": 5.15.0
559+
"@typescript-eslint/scope-manager": 5.16.0
560+
"@typescript-eslint/types": 5.16.0
561+
"@typescript-eslint/typescript-estree": 5.16.0
562562
eslint-scope: ^5.1.1
563563
eslint-utils: ^3.0.0
564564
peerDependencies:
565565
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
566-
checksum: 406725b3e1282064612c9e69f346ceae5cf8e3fe4ae37295eaa1d594fb1b7ed3abd161c32b96622b00ca56e7b1120ea43b584954cd0cefad904a46d65b20960e
566+
checksum: 46749091a204d7cf80d81b04704e23a86903a142a7e35cc5068a821c147c3bf098a7eff99af2b0e2ea7310013ca90300db9bab33ae5e3b5f773ed1d2961a5ed4
567567
languageName: node
568568
linkType: hard
569569

570-
"@typescript-eslint/visitor-keys@npm:5.15.0":
571-
version: 5.15.0
572-
resolution: "@typescript-eslint/visitor-keys@npm:5.15.0"
570+
"@typescript-eslint/visitor-keys@npm:5.16.0":
571+
version: 5.16.0
572+
resolution: "@typescript-eslint/visitor-keys@npm:5.16.0"
573573
dependencies:
574-
"@typescript-eslint/types": 5.15.0
574+
"@typescript-eslint/types": 5.16.0
575575
eslint-visitor-keys: ^3.0.0
576-
checksum: a3f231bf55794547680284aa23ba495efa1e52f864583fe53e1ff8b2c011db070ca48633eb8a333bfc93be0bdbb76ffa98e81bf032fd2737a5e0f0b1b81bbc22
576+
checksum: b587bf3b0da95bb58ff877b75fefcee6472222de1e3ec76aa4b94cae66078b62a372c7d0343374a16aab15cdcbae3f9e019624028b35827f68ef6559389f7fd0
577577
languageName: node
578578
linkType: hard
579579

@@ -2115,9 +2115,9 @@ __metadata:
21152115
languageName: node
21162116
linkType: hard
21172117

2118-
"eslint-plugin-github@npm:^4.3.5":
2119-
version: 4.3.5
2120-
resolution: "eslint-plugin-github@npm:4.3.5"
2118+
"eslint-plugin-github@npm:^4.3.6":
2119+
version: 4.3.6
2120+
resolution: "eslint-plugin-github@npm:4.3.6"
21212121
dependencies:
21222122
"@typescript-eslint/eslint-plugin": ^5.1.0
21232123
"@typescript-eslint/parser": ^5.1.0
@@ -2128,15 +2128,15 @@ __metadata:
21282128
eslint-plugin-i18n-text: ^1.0.1
21292129
eslint-plugin-import: ^2.25.2
21302130
eslint-plugin-no-only-tests: ^2.6.0
2131-
eslint-plugin-prettier: ^3.3.1
2131+
eslint-plugin-prettier: ^4.0.0
21322132
eslint-rule-documentation: ">=1.0.0"
21332133
prettier: ^2.2.1
21342134
svg-element-attributes: ^1.3.1
21352135
peerDependencies:
21362136
eslint: ^8.0.1
21372137
bin:
21382138
eslint-ignore-errors: bin/eslint-ignore-errors.js
2139-
checksum: be31e911d1db493c03a5907d51b4de0d64b4ceb89a72ac774a3b8a5f33fcadf08613720d6dfc82cc5181046fde15fd0cd4cd801194250735b48f4bbe61459815
2139+
checksum: 38ab259fa3c37983dce90a163d4c2c1769ba71a38efa7ef14ee0c1678e0d767dbcb3bef61a6bbd35a1dbcdbd90bb1dc86a2a5334463cb3a2fc21cfb3c73fb5de
21402140
languageName: node
21412141
linkType: hard
21422142

@@ -2235,21 +2235,6 @@ __metadata:
22352235
languageName: node
22362236
linkType: hard
22372237

2238-
"eslint-plugin-prettier@npm:^3.3.1":
2239-
version: 3.4.1
2240-
resolution: "eslint-plugin-prettier@npm:3.4.1"
2241-
dependencies:
2242-
prettier-linter-helpers: ^1.0.0
2243-
peerDependencies:
2244-
eslint: ">=5.0.0"
2245-
prettier: ">=1.13.0"
2246-
peerDependenciesMeta:
2247-
eslint-config-prettier:
2248-
optional: true
2249-
checksum: fa6a89f0d7cba1cc87064352f5a4a68dc3739448dd279bec2bced1bfa3b704467e603d13b69dcec853f8fa30b286b8b715912898e9da776e1b016cf0ee48bd99
2250-
languageName: node
2251-
linkType: hard
2252-
22532238
"eslint-plugin-prettier@npm:^4.0.0":
22542239
version: 4.0.0
22552240
resolution: "eslint-plugin-prettier@npm:4.0.0"

0 commit comments

Comments
 (0)