Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b56464a5f | |||
| 4805687305 | |||
| c387a633bb | |||
| 99efc2d5fe | |||
| e146b7741d | |||
| 02866cbe8d | |||
| 7a320d27a3 | |||
| 7910f9a856 | |||
| 05194609fe | |||
| eb0ec04199 | |||
| ffd5eb2e52 | |||
| c432079a70 | |||
| e2cab0bb59 | |||
| aaaa8b3ee4 | |||
| 4cc149069e | |||
| 6c106a4f22 | |||
| 85fca378ff | |||
| d096a08e42 | |||
| a715dd9e8c | |||
| ef8bf0a0d8 | |||
| f6d8910c45 | |||
| 0917b9dd06 |
@@ -19,23 +19,35 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
audit:
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@@ -50,9 +62,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@@ -63,9 +73,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@@ -85,6 +93,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
|||||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3962
package-lock.json
generated
3962
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@apiglobal/test-sdk",
|
"name": "@apiglobal/test-sdk",
|
||||||
"version": "1.0.16",
|
"version": "1.0.27",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "an sdk for testing ag handlers",
|
"description": "an sdk for testing ag handlers",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@@ -12,18 +12,19 @@
|
|||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tstest": "^1.0.43",
|
"@gitzone/tstest": "^1.0.52",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.9",
|
||||||
"@types/node": "^14.0.26",
|
"@types/node": "^14.14.0",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apiglobal/sdk": "^1.0.9",
|
"@apiglobal/sdk": "^1.0.18",
|
||||||
"@apiglobal/typedrequest": "^1.0.40",
|
"@apiglobal/typedrequest": "^1.0.54",
|
||||||
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
"@apiglobal/typedrequest-interfaces": "^1.0.15",
|
||||||
"@pushrocks/smartexpress": "^3.0.73",
|
"@pushrocks/qenv": "^4.0.10",
|
||||||
|
"@pushrocks/smartexpress": "^3.0.81",
|
||||||
"@pushrocks/smartobject": "^1.0.4"
|
"@pushrocks/smartobject": "^1.0.4"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@@ -37,5 +38,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
43
ts/index.ts
43
ts/index.ts
@@ -1,13 +1,24 @@
|
|||||||
import * as plugins from './test-sdk.plugins';
|
import * as plugins from './test-sdk.plugins';
|
||||||
import { AgTestServer } from './test-sdk.classes.testserver';
|
import { AgTestServer } from './test-sdk.classes.testserver';
|
||||||
|
import { AAgHandler } from '@apiglobal/sdk';
|
||||||
|
|
||||||
export {
|
export { AgTestServer };
|
||||||
AgTestServer
|
|
||||||
};
|
|
||||||
|
|
||||||
let testServer: AgTestServer;
|
let testServer: AgTestServer;
|
||||||
export const createTestServer = async (handlerArg: plugins.agSdk.AAgHandler<any>) => {
|
let handler: AAgHandler<any>;
|
||||||
testServer = new AgTestServer(handlerArg);
|
export const createTestServer = async (handlerArg: {
|
||||||
|
new (envManagerArg: plugins.agSdk.AgEnvironment): plugins.agSdk.AAgHandler<any>;
|
||||||
|
}) => {
|
||||||
|
class AgEnvironement extends plugins.agSdk.AgEnvironment {
|
||||||
|
public qenv = new plugins.qenv.Qenv('./', './.nogit');
|
||||||
|
public async getEnvVar(nameArg: string) {
|
||||||
|
return this.qenv.getEnvVarOnDemand(nameArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handler = new handlerArg(new AgEnvironement());
|
||||||
|
console.log(`now checking requirements for handler with slug ${handler.slug}...`);
|
||||||
|
await handler.checkRequirements();
|
||||||
|
testServer = new AgTestServer(handler);
|
||||||
await testServer.start();
|
await testServer.start();
|
||||||
return testServer;
|
return testServer;
|
||||||
};
|
};
|
||||||
@@ -33,12 +44,21 @@ export const testFire = <
|
|||||||
const responsePromise = typedRequest.fire(requestArg);
|
const responsePromise = typedRequest.fire(requestArg);
|
||||||
const expect = async (expectedResponseArg: T['response']) => {
|
const expect = async (expectedResponseArg: T['response']) => {
|
||||||
const actualResponse = await responsePromise;
|
const actualResponse = await responsePromise;
|
||||||
const comparisonResult = plugins.smartobject.compareObjects(expectedResponseArg, actualResponse);
|
const comparisonResult = plugins.smartobject.compareObjects(
|
||||||
|
expectedResponseArg,
|
||||||
|
actualResponse
|
||||||
|
);
|
||||||
let throwErrorBool = false;
|
let throwErrorBool = false;
|
||||||
if (comparisonResult.divergingProperties.length > 0) {
|
if (comparisonResult.divergingProperties.length > 0) {
|
||||||
console.log(`The following properties diverged:`);
|
console.log(`The following properties diverged:`);
|
||||||
console.log(comparisonResult.divergingProperties);
|
console.log(comparisonResult.divergingProperties);
|
||||||
throwErrorBool = true;
|
for (const divProperty of comparisonResult.divergingProperties) {
|
||||||
|
if (expectedResponseArg[divProperty] !== 'maydiverge') {
|
||||||
|
throwErrorBool = true;
|
||||||
|
} else {
|
||||||
|
console.log(`${divProperty} may diverge, not throwing for this one`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (comparisonResult.missingProperties.length > 0) {
|
if (comparisonResult.missingProperties.length > 0) {
|
||||||
console.log(`The following properties diverged:`);
|
console.log(`The following properties diverged:`);
|
||||||
@@ -46,16 +66,23 @@ export const testFire = <
|
|||||||
throwErrorBool = true;
|
throwErrorBool = true;
|
||||||
}
|
}
|
||||||
if (throwErrorBool) {
|
if (throwErrorBool) {
|
||||||
|
console.log('Result: response did not comply');
|
||||||
|
console.log('-> expected:');
|
||||||
|
console.log(expectedResponseArg);
|
||||||
|
console.log('-> but actually received:');
|
||||||
|
console.log(actualResponse);
|
||||||
throw new Error('response did not comply');
|
throw new Error('response did not comply');
|
||||||
}
|
}
|
||||||
|
return actualResponse;
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
expect
|
expect,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const stopTestServer = async () => {
|
export const stopTestServer = async () => {
|
||||||
if (testServer) {
|
if (testServer) {
|
||||||
await testServer.stop();
|
await testServer.stop();
|
||||||
|
await handler.stop();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
|
|||||||
export { agSdk, typedrequest, typedrequestInterfaces };
|
export { agSdk, typedrequest, typedrequestInterfaces };
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
|
import * as qenv from '@pushrocks/qenv';
|
||||||
import * as smartexpress from '@pushrocks/smartexpress';
|
import * as smartexpress from '@pushrocks/smartexpress';
|
||||||
import * as smartobject from '@pushrocks/smartobject';
|
import * as smartobject from '@pushrocks/smartobject';
|
||||||
|
|
||||||
export { smartexpress, smartobject };
|
export { qenv, smartexpress, smartobject };
|
||||||
|
|||||||
Reference in New Issue
Block a user