Skip to content

Commit

Permalink
chore(packages): consolidate middleware integ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srchase committed Jun 16, 2023
1 parent 3bad043 commit 3926653
Show file tree
Hide file tree
Showing 30 changed files with 324 additions and 39 deletions.
4 changes: 0 additions & 4 deletions packages/middleware-apply-body-checksum/jest.config.integ.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/middleware-apply-body-checksum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"test": "jest --coverage",
"test:integration": "jest --config jest.config.integ.js"
"test": "jest --coverage"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
Expand Down
4 changes: 0 additions & 4 deletions packages/middleware-content-length/jest.config.integ.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/middleware-content-length/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"test": "exit 0",
"test:integration": "jest --config jest.config.integ.js"
"test": "exit 0"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
Expand Down
4 changes: 0 additions & 4 deletions packages/middleware-endpoint/jest.config.integ.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/middleware-endpoint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"test": "jest --passWithNoTests",
"test:integration": "jest -c jest.config.integ.js"
"test": "jest --passWithNoTests"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
Expand Down
4 changes: 0 additions & 4 deletions packages/middleware-retry/jest.config.integ.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/middleware-retry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"test": "jest",
"test:integration": "jest -c jest.config.integ.js"
"test": "jest"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
Expand Down
4 changes: 0 additions & 4 deletions packages/middleware-serde/jest.config.integ.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/middleware-serde/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"test": "jest",
"test:integration": "jest -c jest.config.integ.js"
"test": "jest"
},
"main": "./dist-cjs/index.js",
"module": "./dist-es/index.js",
Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions private/aws-client-retry-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @aws-sdk/aws-client-retry-test

This is not a runtime or published package.

This is a test spec.

The purpose of this package is to perform integration tests on the retry-middleware.

If tests in this package fail, the author should either fix their changes such that the API contract
is maintained, or appropriately announce and safely deprecate the interfaces affected by incoming changes.
7 changes: 5 additions & 2 deletions private/aws-client-retry-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"module": "./dist-es/index.js",
"sideEffects": false,
"dependencies": {
"@aws-sdk/client-xray": "*",
"@aws-sdk/client-s3": "*",
"@aws-sdk/util-retry": "*",
"@smithy/protocol-http": "*",
"@smithy/types": "*",
"tslib": "^2.5.0"
},
"devDependencies": {
Expand Down Expand Up @@ -55,6 +58,6 @@
"repository": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-js-v3.git",
"directory": "private/aws-client-api-test"
"directory": "private/aws-client-retry-test"
}
}
4 changes: 4 additions & 0 deletions private/aws-middleware-test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 changes: 5 additions & 0 deletions private/aws-middleware-test/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const base = require("../../jest.config.base.js");

module.exports = {
...base,
};
67 changes: 67 additions & 0 deletions private/aws-middleware-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "@aws-sdk/aws-middleware-test",
"description": "Integration test suite for AWS middleware",
"version": "3.0.0",
"scripts": {
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:es": "tsc -p tsconfig.es.json",
"build:include:deps": "lerna run --scope $npm_package_name --include-dependencies build",
"build:types": "tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"test": "jest --coverage --passWithNoTests"
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
"module": "./dist-es/index.js",
"sideEffects": false,
"dependencies": {
"@aws-sdk/client-accessanalyzer": "*",
"@aws-sdk/client-ec2": "*",
"@aws-sdk/client-lambda": "*",
"@aws-sdk/client-s3": "*",
"@aws-sdk/client-s3-control": "*",
"@aws-sdk/client-sagemaker": "*",
"@aws-sdk/client-sagemaker-runtime": "*",
"@aws-sdk/client-xray": "*",
"tslib": "^2.5.0"
},
"devDependencies": {
"@tsconfig/node14": "1.0.3",
"@types/node": "^12.7.5",
"concurrently": "7.0.0",
"downlevel-dts": "0.10.1",
"typedoc": "0.23.23",
"typescript": "~4.9.5"
},
"overrides": {
"typedoc": {
"typescript": "~4.9.5"
}
},
"engines": {
"node": ">=14.0.0"
},
"typesVersions": {
"<4.0": {
"dist-types/*": [
"dist-types/ts3.4/*"
]
}
},
"files": [
"dist-*/**"
],
"author": {
"name": "AWS SDK for JavaScript Team",
"url": "https://aws.amazon.com/javascript/"
},
"license": "Apache-2.0",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-js-v3.git",
"directory": "private/aws-middleware-test"
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# @aws-sdk/aws-client-api-test
# @aws-sdk/aws-middleware-test

This is not a runtime or published package.

This is a test spec.

The purpose of this package is to perform integration tests on the retry-middleware.
The purpose of this package is to perform integration tests on the AWS middleware.

If tests in this package fail, the author should either fix their changes such that the API contract
is maintained, or appropriately announce and safely deprecate the interfaces affected by incoming changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { S3Control } from "@aws-sdk/client-s3-control";

import { requireRequestsFrom } from "../../../private/aws-util-test/src";
import { requireRequestsFrom } from "../../aws-util-test/src";

describe("middleware-apply-body-checksum", () => {
describe(S3Control.name, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AccessAnalyzer } from "@aws-sdk/client-accessanalyzer";
import { S3 } from "@aws-sdk/client-s3";
import { XRay } from "@aws-sdk/client-xray";

import { requireRequestsFrom } from "../../../private/aws-util-test/src";
import { requireRequestsFrom } from "../../aws-util-test/src";

describe("middleware-content-length", () => {
describe(AccessAnalyzer.name, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { S3 } from "@aws-sdk/client-s3";
import { S3Control } from "@aws-sdk/client-s3-control";

import { requireRequestsFrom } from "../../../private/aws-util-test/src";
import { requireRequestsFrom } from "../../aws-util-test/src";

describe("middleware-endpoint", () => {
// these are token examples because most endpoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Lambda } from "@aws-sdk/client-lambda";

import { requireRequestsFrom } from "../../../private/aws-util-test/src";
import { requireRequestsFrom } from "../../aws-util-test/src";

describe("middleware-retry", () => {
describe(Lambda.name, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { S3 } from "@aws-sdk/client-s3";
import { SageMaker } from "@aws-sdk/client-sagemaker";
import { SageMakerRuntime } from "@aws-sdk/client-sagemaker-runtime";

import { requireRequestsFrom } from "../../../private/aws-util-test/src";
import { requireRequestsFrom } from "../../aws-util-test/src";

describe("middleware-serde", () => {
describe(S3.name, () => {
Expand Down
6 changes: 6 additions & 0 deletions private/aws-middleware-test/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"outDir": "dist-cjs"
}
}
8 changes: 8 additions & 0 deletions private/aws-middleware-test/tsconfig.es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"lib": ["dom"],
"module": "esnext",
"outDir": "dist-es"
}
}
13 changes: 13 additions & 0 deletions private/aws-middleware-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"downlevelIteration": true,
"importHelpers": true,
"incremental": true,
"removeComments": true,
"resolveJsonModule": true,
"rootDir": "src",
"useUnknownInCatchVariables": false
},
"exclude": ["test/"]
}
10 changes: 10 additions & 0 deletions private/aws-middleware-test/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"removeComments": false,
"declaration": true,
"declarationDir": "dist-types",
"emitDeclarationOnly": true
},
"exclude": ["test/**/*", "dist-types/**/*"]
}
1 change: 1 addition & 0 deletions private/aws-util-test/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./requests/test-http-handler";
1 change: 1 addition & 0 deletions private/aws-util-test/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./requests/test-http-handler";
65 changes: 65 additions & 0 deletions private/aws-util-test/src/requests/test-http-handler.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { HttpHandler, HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import { Client, HttpHandlerOptions, RequestHandlerOutput } from "@aws-sdk/types";
/**
* Instructs {@link TestHttpHandler} how to match the handled request and the expected request.
* @internal
*/
export type Matcher = string | number | boolean | RegExp | null | undefined | ((value: any) => void);
/**
* @internal
*/
export type HttpRequestMatcher = {
protocol?: Matcher;
hostname?: Matcher;
port?: Matcher;
path?: Matcher;
query?: Record<string, Matcher> | Map<RegExp | string, Matcher>;
headers?: Record<string, Matcher> | Map<RegExp | string, Matcher>;
body?: Matcher;
method?: Matcher;
log?: boolean;
};
/**
* Supplied to test clients to assert correct requests.
* @internal
*/
export declare class TestHttpHandler implements HttpHandler {
readonly matcher: HttpRequestMatcher;
private static WATCHER;
private originalSend?;
private originalRequestHandler?;
private client?;
private assertions;
constructor(matcher: HttpRequestMatcher);
/**
* @param client - to watch for requests.
* @param matcher - optional override of this instance's matchers.
*
* Temporarily hooks the client.send call to check the outgoing request.
*/
watch(client: Client<any, any, any>, matcher?: HttpRequestMatcher): void;
/**
* @throws TestHttpHandlerSuccess to indicate success (only way to control it).
* @throws Error any other exception to indicate failure.
*/
handle(request: HttpRequest, handlerOptions?: HttpHandlerOptions): Promise<RequestHandlerOutput<HttpResponse>>;
destroy(): Promise<void>;
private check;
private checkAll;
}
/**
* This is used as an interrupt signal for success.
* It does not indicate a true error.
*
* @internal
*/
export declare class TestHttpHandlerSuccess extends Error {
static readonly ID: unique symbol;
readonly id: symbol;
}
/**
* @internal
*/
export declare const requireRequestsFrom: (client: Client<any, any, any>) => {
toMatch(matcher: HttpRequestMatcher): void;
};
Loading

0 comments on commit 3926653

Please sign in to comment.