Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
c36459dfcc | |||
36903d2d6c | |||
c54493ddbc | |||
e98f109dcc | |||
32704386ee | |||
8ec3d593c1 | |||
f3f05b89d9 | |||
7104c8b1b5 | |||
dcb4ee301b | |||
df12f0ad83 | |||
01823fb683 | |||
649e69e1f2 | |||
05a361046e | |||
a551989f8b | |||
7f765c08e4 | |||
4e7b5a693d | |||
20e36fbdf2 | |||
a61d87a9a0 |
@ -6,8 +6,8 @@ on:
|
|||||||
- '**'
|
- '**'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
IMAGE: code.foss.global/hosttoday/ht-docker-node:npmci
|
||||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Install pnpm and npmci
|
- name: Install pnpm and npmci
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @shipzone/npmci
|
pnpm install -g @ship.zone/npmci
|
||||||
|
|
||||||
- name: Run npm prepare
|
- name: Run npm prepare
|
||||||
run: npmci npm prepare
|
run: npmci npm prepare
|
||||||
|
@ -6,8 +6,8 @@ on:
|
|||||||
- '*'
|
- '*'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
IMAGE: code.foss.global/hosttoday/ht-docker-node:npmci
|
||||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @shipzone/npmci
|
pnpm install -g @ship.zone/npmci
|
||||||
npmci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Audit production dependencies
|
- name: Audit production dependencies
|
||||||
@ -54,7 +54,7 @@ jobs:
|
|||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @shipzone/npmci
|
pnpm install -g @ship.zone/npmci
|
||||||
npmci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Test stable
|
- name: Test stable
|
||||||
@ -82,7 +82,7 @@ jobs:
|
|||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @shipzone/npmci
|
pnpm install -g @ship.zone/npmci
|
||||||
npmci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
@ -104,7 +104,7 @@ jobs:
|
|||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
pnpm install -g pnpm
|
pnpm install -g pnpm
|
||||||
pnpm install -g @shipzone/npmci
|
pnpm install -g @ship.zone/npmci
|
||||||
npmci npm prepare
|
npmci npm prepare
|
||||||
|
|
||||||
- name: Code quality
|
- name: Code quality
|
||||||
|
54
changelog.md
54
changelog.md
@ -1,5 +1,59 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2024-11-06 - 5.5.0 - feat(tapnodetools)
|
||||||
|
Add TestFileProvider for handling Docker Alpine image
|
||||||
|
|
||||||
|
- Introduced TestFileProvider in TapNodeTools.
|
||||||
|
- Added method to retrieve Docker Alpine image as a local tarball.
|
||||||
|
|
||||||
|
## 2024-11-06 - 5.4.4 - fix(dependencies)
|
||||||
|
Update smarts3 dependency to version 2.2.5
|
||||||
|
|
||||||
|
|
||||||
|
## 2024-11-06 - 5.4.3 - fix(TapNodeTools)
|
||||||
|
Fix server port default value in createSmarts3 method
|
||||||
|
|
||||||
|
- The `createSmarts3` method in `TapNodeTools` now explicitly sets the port to 3003.
|
||||||
|
|
||||||
|
## 2024-11-06 - 5.4.2 - fix(dependencies)
|
||||||
|
Update smarts3 dependency version to fix issues.
|
||||||
|
|
||||||
|
- Changed the version of @push.rocks/smarts3 from ^2.2.1 to ^2.2.2.
|
||||||
|
|
||||||
|
## 2024-11-06 - 5.4.1 - fix(ci)
|
||||||
|
Fix CI configuration URL and package installation paths.
|
||||||
|
|
||||||
|
- Updated Docker image URL in CI config.
|
||||||
|
- Fixed repository URL format in package.json.
|
||||||
|
- Corrected npmci package installation path.
|
||||||
|
|
||||||
|
## 2024-11-06 - 5.4.0 - feat(node)
|
||||||
|
Add smartmongo and smarts3 integration in node tools
|
||||||
|
|
||||||
|
- Added createSmartmongo method to TapNodeTools for creating SmartMongo instances.
|
||||||
|
- Added createSmarts3 method to TapNodeTools for creating Smarts3 instances.
|
||||||
|
- Updated dependencies with smartmongo and smarts3 in package.json.
|
||||||
|
|
||||||
|
## 2024-09-19 - 5.3.0 - feat(TapNodeTools)
|
||||||
|
Add getEnvVarOnDemand method to TapNodeTools
|
||||||
|
|
||||||
|
- Introduced a new method getEnvVarOnDemand to the TapNodeTools class to fetch environment variables on demand.
|
||||||
|
- Enhanced getQenv function in TapNodeTools class to cache the Qenv instance for better performance.
|
||||||
|
|
||||||
|
## 2024-09-19 - 5.2.2 - fix(core)
|
||||||
|
Ensure reliability in test setup and execution
|
||||||
|
|
||||||
|
- Added new pre-task functionality to log starting of tasks.
|
||||||
|
- Enhanced `runCommand` method to better handle shell command execution.
|
||||||
|
- Fixed issue in `createHttpsCert` to correctly generate self-signed certificates.
|
||||||
|
|
||||||
|
## 2024-09-19 - 5.2.1 - fix(tapbundle)
|
||||||
|
Add qenv package to dependencies for environment management
|
||||||
|
|
||||||
|
- Added @push.rocks/qenv to dependencies in package.json.
|
||||||
|
- Updated TapNodeTools class in ts_node/classes.tapnodetools.ts to include getQenv method.
|
||||||
|
- Imported qenv in ts_node/plugins.ts.
|
||||||
|
|
||||||
## 2024-09-18 - 5.2.0 - feat(TapNodeTools)
|
## 2024-09-18 - 5.2.0 - feat(TapNodeTools)
|
||||||
Add ability to create HTTPS certificates with self-signed option
|
Add ability to create HTTPS certificates with self-signed option
|
||||||
|
|
||||||
|
14
package.json
14
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/tapbundle",
|
"name": "@push.rocks/tapbundle",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "5.2.0",
|
"version": "5.5.0",
|
||||||
"description": "A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.",
|
"description": "A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./dist_ts/index.js",
|
".": "./dist_ts/index.js",
|
||||||
@ -15,23 +15,29 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://code.foss.global/push.rocks/tapbundle.git"
|
"url": "git+https://code.foss.global/push.rocks/tapbundle.git"
|
||||||
},
|
},
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/tapbundle/issues"
|
"url": "https://code.foss.global/push.rocks/tapbundle/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://code.foss.global/push.rocks/tapbundle",
|
"homepage": "https://code.foss.global/push.rocks/tapbundle#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@open-wc/testing": "^4.0.0",
|
"@open-wc/testing": "^4.0.0",
|
||||||
"@push.rocks/consolecolor": "^2.0.2",
|
"@push.rocks/consolecolor": "^2.0.2",
|
||||||
|
"@push.rocks/qenv": "^6.0.5",
|
||||||
"@push.rocks/smartcrypto": "^2.0.4",
|
"@push.rocks/smartcrypto": "^2.0.4",
|
||||||
"@push.rocks/smartdelay": "^3.0.5",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartenv": "^5.0.12",
|
"@push.rocks/smartenv": "^5.0.12",
|
||||||
"@push.rocks/smartexpect": "^1.2.1",
|
"@push.rocks/smartexpect": "^1.2.1",
|
||||||
|
"@push.rocks/smartfile": "^11.0.21",
|
||||||
"@push.rocks/smartjson": "^5.0.20",
|
"@push.rocks/smartjson": "^5.0.20",
|
||||||
|
"@push.rocks/smartmongo": "^2.0.10",
|
||||||
|
"@push.rocks/smartpath": "^5.0.18",
|
||||||
"@push.rocks/smartpromise": "^4.0.4",
|
"@push.rocks/smartpromise": "^4.0.4",
|
||||||
|
"@push.rocks/smartrequest": "^2.0.23",
|
||||||
|
"@push.rocks/smarts3": "^2.2.5",
|
||||||
"@push.rocks/smartshell": "^3.0.6",
|
"@push.rocks/smartshell": "^3.0.6",
|
||||||
"@push.rocks/smarttime": "^4.0.8"
|
"@push.rocks/smarttime": "^4.0.8"
|
||||||
},
|
},
|
||||||
|
9612
pnpm-lock.yaml
generated
9612
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
12
readme.md
12
readme.md
@ -1,7 +1,9 @@
|
|||||||
# @push.rocks/tapbundle
|
# @push.rocks/tapbundle
|
||||||
|
|
||||||
tap bundled for tapbuffer
|
tap bundled for tapbuffer
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Install the package by running the following command in your terminal:
|
Install the package by running the following command in your terminal:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -11,9 +13,11 @@ npm install @push.rocks/tapbundle --save-dev
|
|||||||
This will add `@push.rocks/tapbundle` to your project's `devDependencies`.
|
This will add `@push.rocks/tapbundle` to your project's `devDependencies`.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The `@push.rocks/tapbundle` package is a tap-compatible testing framework written in TypeScript, intended for use with tapbuffer. It includes a range of useful features enabling easy setup and execution of tests, assertion handling through `expect` and `expectAsync`, as well as auxiliary tools for delay and colored console output.
|
The `@push.rocks/tapbundle` package is a tap-compatible testing framework written in TypeScript, intended for use with tapbuffer. It includes a range of useful features enabling easy setup and execution of tests, assertion handling through `expect` and `expectAsync`, as well as auxiliary tools for delay and colored console output.
|
||||||
|
|
||||||
### Getting Started
|
### Getting Started
|
||||||
|
|
||||||
First, ensure your project is set up with Typescript and supports ESM syntax. You can then import `tap`, `expect`, and `expectAsync` from `@push.rocks/tapbundle` to start defining your tests.
|
First, ensure your project is set up with Typescript and supports ESM syntax. You can then import `tap`, `expect`, and `expectAsync` from `@push.rocks/tapbundle` to start defining your tests.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -33,6 +37,7 @@ tap.start();
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Defining Tests
|
### Defining Tests
|
||||||
|
|
||||||
You can define tests with descriptions and async functions. The `tap` instance manages test execution, supports test skipping, and managing exclusive tests with the `.only` modifier.
|
You can define tests with descriptions and async functions. The `tap` instance manages test execution, supports test skipping, and managing exclusive tests with the `.only` modifier.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -52,6 +57,7 @@ tap.start();
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Using `expect` and `expectAsync`
|
### Using `expect` and `expectAsync`
|
||||||
|
|
||||||
The package provides `expect` and `expectAsync` for assertions:
|
The package provides `expect` and `expectAsync` for assertions:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -60,6 +66,7 @@ expect(5).toBeGreaterThan(2);
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Handling Asynchronous Operations
|
### Handling Asynchronous Operations
|
||||||
|
|
||||||
`tapbundle` facilitates working with async operations in tests. You can introduce delays or set timeouts:
|
`tapbundle` facilitates working with async operations in tests. You can introduce delays or set timeouts:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -72,7 +79,9 @@ tap.start();
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Advanced Usage
|
### Advanced Usage
|
||||||
|
|
||||||
#### Pre Tasks
|
#### Pre Tasks
|
||||||
|
|
||||||
You can define tasks to run before test execution begins:
|
You can define tasks to run before test execution begins:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -88,6 +97,7 @@ tap.start();
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Accessing Test Metadata
|
#### Accessing Test Metadata
|
||||||
|
|
||||||
Each test returns a `TapTest` instance, from which you can access metadata and manipulate test behavior:
|
Each test returns a `TapTest` instance, from which you can access metadata and manipulate test behavior:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
@ -102,9 +112,11 @@ tap.start().then(() => {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Running Tests
|
### Running Tests
|
||||||
|
|
||||||
Tests are executed by calling `tap.start()`. This method runs all defined tests in sequence and respects `.skip` and `.only` modifiers.
|
Tests are executed by calling `tap.start()`. This method runs all defined tests in sequence and respects `.skip` and `.only` modifiers.
|
||||||
|
|
||||||
### Debugging and Output
|
### Debugging and Output
|
||||||
|
|
||||||
`@push.rocks/tapbundle` supports colored console output via `consolecolor` to help with debugging and test result readability:
|
`@push.rocks/tapbundle` supports colored console output via `consolecolor` to help with debugging and test result readability:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
@ -23,10 +23,10 @@ const test3 = tap.test(
|
|||||||
async () => {
|
async () => {
|
||||||
expect(
|
expect(
|
||||||
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
||||||
(await test2).hrtMeasurement.milliSeconds
|
(await test2).hrtMeasurement.milliSeconds,
|
||||||
).toBeTrue();
|
).toBeTrue();
|
||||||
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 10).toBeTrue();
|
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 10).toBeTrue();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
|
const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => {
|
||||||
|
@ -15,4 +15,14 @@ tap.test('should create a https cert', async () => {
|
|||||||
expect(cert).toInclude('-----BEGIN CERTIFICATE-----');
|
expect(cert).toInclude('-----BEGIN CERTIFICATE-----');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should create a smartmongo instance', async () => {
|
||||||
|
const smartmongo = await tapNodeTools.createSmartmongo();
|
||||||
|
await smartmongo.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should create a smarts3 instance', async () => {
|
||||||
|
const smarts3 = await tapNodeTools.createSmarts3();
|
||||||
|
await smarts3.stop();
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -17,10 +17,10 @@ const test3 = tap.test(
|
|||||||
async () => {
|
async () => {
|
||||||
expect(
|
expect(
|
||||||
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
(await test1.testPromise).hrtMeasurement.milliSeconds <
|
||||||
(await test2).hrtMeasurement.milliSeconds
|
(await test2).hrtMeasurement.milliSeconds,
|
||||||
).toBeTrue();
|
).toBeTrue();
|
||||||
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).toBeTrue();
|
expect((await test2.testPromise).hrtMeasurement.milliSeconds > 1000).toBeTrue();
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const test4 = tap.test('my 4th test -> should fail', async (tools) => {
|
const test4 = tap.test('my 4th test -> should fail', async (tools) => {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/tapbundle',
|
name: '@push.rocks/tapbundle',
|
||||||
version: '5.2.0',
|
version: '5.5.0',
|
||||||
description: 'A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.'
|
description: 'A test automation library bundling utilities and tools for TAP (Test Anything Protocol) based testing, specifically tailored for tapbuffer.'
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ export class Tap<T> {
|
|||||||
public test(
|
public test(
|
||||||
testDescription: string,
|
testDescription: string,
|
||||||
testFunction: ITestFunction<T>,
|
testFunction: ITestFunction<T>,
|
||||||
modeArg: 'normal' | 'only' | 'skip' = 'normal'
|
modeArg: 'normal' | 'only' | 'skip' = 'normal',
|
||||||
): TapTest<T> {
|
): TapTest<T> {
|
||||||
const localTest = new TapTest<T>({
|
const localTest = new TapTest<T>({
|
||||||
description: testDescription,
|
description: testDescription,
|
||||||
@ -67,7 +67,7 @@ export class Tap<T> {
|
|||||||
description: testDescription,
|
description: testDescription,
|
||||||
testFunction,
|
testFunction,
|
||||||
parallel: true,
|
parallel: true,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ export class Tap<T> {
|
|||||||
failReasons.push(
|
failReasons.push(
|
||||||
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
`Test ${tapTest.testKey + 1} failed with status ${tapTest.status}:\n` +
|
||||||
`|| ${tapTest.description}\n` +
|
`|| ${tapTest.description}\n` +
|
||||||
`|| for more information please take a look the logs above`
|
`|| for more information please take a look the logs above`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ export class Tap<T> {
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
process.exit(codeArg);
|
process.exit(codeArg);
|
||||||
}, 10)
|
}, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ export class TapTest<T = unknown> {
|
|||||||
}
|
}
|
||||||
this.hrtMeasurement.stop();
|
this.hrtMeasurement.stop();
|
||||||
console.log(
|
console.log(
|
||||||
`ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`
|
`ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`,
|
||||||
);
|
);
|
||||||
this.status = 'success';
|
this.status = 'success';
|
||||||
this.testDeferred.resolve(this);
|
this.testDeferred.resolve(this);
|
||||||
@ -64,7 +64,7 @@ export class TapTest<T = unknown> {
|
|||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this.hrtMeasurement.stop();
|
this.hrtMeasurement.stop();
|
||||||
console.log(
|
console.log(
|
||||||
`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`
|
`not ok ${testNumber} - ${this.description} # time=${this.hrtMeasurement.milliSeconds}ms`,
|
||||||
);
|
);
|
||||||
this.testDeferred.resolve(this);
|
this.testDeferred.resolve(this);
|
||||||
this.testResultDeferred.resolve(err);
|
this.testResultDeferred.resolve(err);
|
||||||
|
@ -1,10 +1,22 @@
|
|||||||
|
import { TestFileProvider } from './classes.testfileprovider.js';
|
||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
class TapNodeTools {
|
class TapNodeTools {
|
||||||
private smartshellInstance: plugins.smartshell.Smartshell;
|
private smartshellInstance: plugins.smartshell.Smartshell;
|
||||||
|
public testFileProvider = new TestFileProvider();
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
|
private qenv: plugins.qenv.Qenv;
|
||||||
|
public async getQenv(): Promise<plugins.qenv.Qenv> {
|
||||||
|
this.qenv = this.qenv || new plugins.qenv.Qenv('./', '.nogit/');
|
||||||
|
return this.qenv;
|
||||||
|
}
|
||||||
|
public async getEnvVarOnDemand(envVarNameArg: string): Promise<string> {
|
||||||
|
const qenv = await this.getQenv();
|
||||||
|
return qenv.getEnvVarOnDemand(envVarNameArg);
|
||||||
|
}
|
||||||
|
|
||||||
public async runCommand(commandArg: string): Promise<any> {
|
public async runCommand(commandArg: string): Promise<any> {
|
||||||
if (!this.smartshellInstance) {
|
if (!this.smartshellInstance) {
|
||||||
this.smartshellInstance = new plugins.smartshell.Smartshell({
|
this.smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
@ -58,6 +70,29 @@ class TapNodeTools {
|
|||||||
cert: pemCert,
|
cert: pemCert,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create and return a smartmongo instance
|
||||||
|
*/
|
||||||
|
public async createSmartmongo() {
|
||||||
|
const smartmongoMod = await import('@push.rocks/smartmongo');
|
||||||
|
const smartmongoInstance = new smartmongoMod.SmartMongo();
|
||||||
|
await smartmongoInstance.start();
|
||||||
|
return smartmongoInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create and return a smarts3 instance
|
||||||
|
*/
|
||||||
|
public async createSmarts3() {
|
||||||
|
const smarts3Mod = await import('@push.rocks/smarts3');
|
||||||
|
const smarts3Instance = new smarts3Mod.Smarts3({
|
||||||
|
port: 3003,
|
||||||
|
cleanSlate: true,
|
||||||
|
});
|
||||||
|
await smarts3Instance.start();
|
||||||
|
return smarts3Instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tapNodeTools = new TapNodeTools();
|
export const tapNodeTools = new TapNodeTools();
|
||||||
|
17
ts_node/classes.testfileprovider.ts
Normal file
17
ts_node/classes.testfileprovider.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import * as plugins from './plugins.js';
|
||||||
|
import * as paths from './paths.js';
|
||||||
|
|
||||||
|
export const fileUrls = {
|
||||||
|
dockerAlpineImage: 'https://code.foss.global/testassets/docker/raw/branch/main/alpine.tar',
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TestFileProvider {
|
||||||
|
public async getDockerAlpineImageAsLocalTarball(): Promise<string> {
|
||||||
|
const filePath = plugins.path.join(paths.testFilesDir, 'alpine.tar')
|
||||||
|
// fetch the docker alpine image
|
||||||
|
const response = await plugins.smartrequest.getBinary(fileUrls.dockerAlpineImage);
|
||||||
|
await plugins.smartfile.fs.ensureDir(paths.testFilesDir);
|
||||||
|
const AlpineBuffer = await plugins.smartfile.memory.toFs(response.body, filePath);
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
}
|
4
ts_node/paths.ts
Normal file
4
ts_node/paths.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
|
export const cwd = process.cwd();
|
||||||
|
export const testFilesDir = plugins.path.join(cwd, './.nogit/testfiles/');
|
@ -1,11 +1,16 @@
|
|||||||
// node native
|
// node native
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
export { crypto,fs };
|
export { crypto,fs, path, };
|
||||||
|
|
||||||
// @push.rocks scope
|
// @push.rocks scope
|
||||||
|
import * as qenv from '@push.rocks/qenv';
|
||||||
import * as smartcrypto from '@push.rocks/smartcrypto';
|
import * as smartcrypto from '@push.rocks/smartcrypto';
|
||||||
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
|
import * as smartrequest from '@push.rocks/smartrequest';
|
||||||
import * as smartshell from '@push.rocks/smartshell';
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
|
||||||
export { smartcrypto, smartshell };
|
export { qenv, smartcrypto, smartfile, smartpath, smartrequest, smartshell, };
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {}
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist_*/**/*.d.ts"
|
"dist_*/**/*.d.ts"
|
||||||
|
Reference in New Issue
Block a user