@toa.io/userland 1.0.0-alpha.7 → 1.0.0-alpha.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -11
- package/readme.md +0 -2
- package/stage/src/component.js +0 -5
- package/stage/src/composition.js +0 -4
- package/stage/src/index.js +0 -2
- package/stage/src/shutdown.js +0 -2
- package/stage/test/composition.test.js +0 -11
- package/stage/test/shutdown.test.js +1 -10
- package/stage/types/index.d.ts +0 -2
- package/example/components/echo/samples/get.yaml +0 -12
- package/example/components/echo/samples/signal.yaml +0 -4
- package/example/components/math.calculations/samples/add.yaml +0 -10
- package/example/components/math.calculations/samples/assets/ab.yaml +0 -2
- package/example/components/math.calculations/samples/increment.yaml +0 -27
- package/example/components/math.proxy/samples/add.yaml +0 -11
- package/example/components/tea.pots/samples/same.yaml +0 -8
- package/example/components/tea.pots/samples/transit.yaml +0 -43
- package/example/components/web/samples/get.yaml +0 -8
- package/example/samples/math.proxy.add.yaml +0 -5
- package/example/samples/messages/store.orders.created.yaml +0 -8
- package/samples/docs/sampling-dark.jpg +0 -0
- package/samples/docs/sampling-light.jpg +0 -0
- package/samples/notes.md +0 -12
- package/samples/package.json +0 -5
- package/samples/readme.md +0 -131
- package/samples/src/.replay/.suite/component.js +0 -20
- package/samples/src/.replay/.suite/index.js +0 -7
- package/samples/src/.replay/.suite/messages.js +0 -39
- package/samples/src/.replay/.suite/operation.js +0 -28
- package/samples/src/.replay/.suite/operations.js +0 -20
- package/samples/src/.replay/.suite/translate/.message/index.js +0 -5
- package/samples/src/.replay/.suite/translate/.message/request.js +0 -31
- package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.js +0 -20
- package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.test.js +0 -94
- package/samples/src/.replay/.suite/translate/.operation/.prepare/expand.js +0 -14
- package/samples/src/.replay/.suite/translate/.operation/.prepare/index.js +0 -7
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/.aspect.js +0 -26
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/configuration.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/http.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/index.js +0 -9
- package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/state.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/async.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/cast.js +0 -26
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/index.js +0 -5
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/map.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/set.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/.prepare/types/sync.js +0 -3
- package/samples/src/.replay/.suite/translate/.operation/calls.js +0 -49
- package/samples/src/.replay/.suite/translate/.operation/cleanup.js +0 -16
- package/samples/src/.replay/.suite/translate/.operation/events.js +0 -16
- package/samples/src/.replay/.suite/translate/.operation/index.js +0 -11
- package/samples/src/.replay/.suite/translate/.operation/prepare.js +0 -14
- package/samples/src/.replay/.suite/translate/index.js +0 -7
- package/samples/src/.replay/.suite/translate/message.js +0 -26
- package/samples/src/.replay/.suite/translate/operation.js +0 -47
- package/samples/src/.replay/.suite/translate/schemas/index.js +0 -7
- package/samples/src/.replay/.suite/translate/schemas/message.cos.yaml +0 -10
- package/samples/src/.replay/.suite/translate/schemas/operation.cos.yaml +0 -23
- package/samples/src/.replay/index.js +0 -7
- package/samples/src/.replay/stage.js +0 -60
- package/samples/src/.replay/suite.js +0 -23
- package/samples/src/.replay/test.js +0 -19
- package/samples/src/components.js +0 -13
- package/samples/src/context.js +0 -23
- package/samples/src/index.js +0 -9
- package/samples/src/replay.js +0 -16
- package/samples/src/suite/.read/filter.js +0 -15
- package/samples/src/suite/.read/index.js +0 -7
- package/samples/src/suite/.read/messages.js +0 -40
- package/samples/src/suite/.read/operations.js +0 -51
- package/samples/src/suite/.read/parse.js +0 -20
- package/samples/src/suite/components.js +0 -31
- package/samples/src/suite/context.js +0 -20
- package/samples/src/suite/index.js +0 -7
- package/samples/test/components.test.js +0 -42
- package/samples/test/context/components/dummy/manifest.toa.yaml +0 -2
- package/samples/test/context/components/dummy/samples/do.yaml +0 -11
- package/samples/test/context/components/dummy/samples/dummies.dummy.do.yaml +0 -11
- package/samples/test/context/components/dummy/samples/dummies.dummy.undo.yaml +0 -7
- package/samples/test/context/components/dummy/samples/messages/somewhere.something.happened.yaml +0 -6
- package/samples/test/context/components/pot/manifest.toa.yaml +0 -2
- package/samples/test/context/components/pot/samples/do.yaml +0 -11
- package/samples/test/context/components/pot/samples/messages/somewhere.something.happened.yaml +0 -6
- package/samples/test/context/context.toa.yaml +0 -3
- package/samples/test/context/samples/dummies.dummy.observe.yaml +0 -6
- package/samples/test/context/samples/dummies.dummy.transit.yaml +0 -10
- package/samples/test/context/samples/messages/somewhere.something.happened.yaml +0 -6
- package/samples/test/context.fixtures.js +0 -8
- package/samples/test/context.test.js +0 -82
- package/samples/test/replay.mock.js +0 -7
- package/samples/test/replay.test.js +0 -152
- package/samples/test/replay.translate.message.fixtures.js +0 -24
- package/samples/test/replay.translate.message.test.js +0 -119
- package/samples/test/replay.translate.mock.js +0 -17
- package/samples/test/replay.translate.operation.fixtures.js +0 -107
- package/samples/test/replay.translate.operation.test.js +0 -68
- package/samples/test/stage.mock.js +0 -30
- package/samples/test/suite.components.test.js +0 -122
- package/samples/test/suite.context.test.js +0 -79
- package/samples/test/suite.mock.js +0 -10
- package/samples/types/index.d.ts +0 -8
- package/samples/types/message.d.ts +0 -24
- package/samples/types/operation.d.ts +0 -36
- package/samples/types/replay.d.ts +0 -13
- package/samples/types/suite.d.ts +0 -31
- package/stage/src/binding/binding.js +0 -50
- package/stage/src/binding/consumer.js +0 -30
- package/stage/src/binding/emitter.js +0 -26
- package/stage/src/binding/factory.js +0 -49
- package/stage/src/binding/index.js +0 -10
- package/stage/src/binding/label.js +0 -12
- package/stage/src/binding/producer.js +0 -43
- package/stage/src/binding/receiver.js +0 -34
- package/stage/test/binding/binding.test.js +0 -15
- package/stage/test/binding/consumer.test.js +0 -52
- package/stage/test/binding/emitter.test.js +0 -54
- package/stage/test/binding/producer.fixtures.js +0 -10
- package/stage/test/binding/producer.test.js +0 -49
- package/stage/test/binding/receiver.fixtures.js +0 -7
- package/stage/test/binding/receiver.test.js +0 -54
- package/stage/test/binding.mock.js +0 -8
- package/stage/types/binding.d.ts +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/userland",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.75",
|
|
4
4
|
"description": "Toa development kit",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"url": "https://github.com/toa-io/toa/issues"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": ">= 20.0.0"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
@@ -24,15 +24,14 @@
|
|
|
24
24
|
"main": "src/index.js",
|
|
25
25
|
"types": "types/index.d.ts",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@toa.io/boot": "1.0.0-alpha.
|
|
28
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
29
|
-
"@toa.io/filesystem": "1.0.0-alpha.
|
|
30
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
31
|
-
"@toa.io/norm": "1.0.0-alpha.
|
|
32
|
-
"@toa.io/schemas": "1.0.0-alpha.
|
|
27
|
+
"@toa.io/boot": "1.0.0-alpha.75",
|
|
28
|
+
"@toa.io/core": "1.0.0-alpha.75",
|
|
29
|
+
"@toa.io/filesystem": "1.0.0-alpha.63",
|
|
30
|
+
"@toa.io/generic": "1.0.0-alpha.63",
|
|
31
|
+
"@toa.io/norm": "1.0.0-alpha.75",
|
|
32
|
+
"@toa.io/schemas": "1.0.0-alpha.63",
|
|
33
33
|
"@toa.io/storages.null": "0.22.0",
|
|
34
|
-
"@toa.io/yaml": "1.0.0-alpha.
|
|
35
|
-
"tap": "16.3.4"
|
|
34
|
+
"@toa.io/yaml": "1.0.0-alpha.63"
|
|
36
35
|
},
|
|
37
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "5050fff4a676bbcd7b6f89c1788411701b7ecba6"
|
|
38
37
|
}
|
package/readme.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Toa development kit
|
|
2
2
|
|
|
3
3
|
- [Stage](./stage): integration tests framework (Node.js)
|
|
4
|
-
- [Samples](./samples): YAML-based declarative tests
|
|
5
|
-
- Features[^1]: Gherkin steps definition ([cucumber.js](https://github.com/cucumber/cucumber-js))
|
|
6
4
|
|
|
7
5
|
See [example](./example).
|
|
8
6
|
|
package/stage/src/component.js
CHANGED
|
@@ -5,8 +5,6 @@ const { state } = require('./state')
|
|
|
5
5
|
|
|
6
6
|
/** @type {toa.stage.Component} */
|
|
7
7
|
const component = async (path, options) => {
|
|
8
|
-
options = Object.assign({}, DEFAULTS, options)
|
|
9
|
-
|
|
10
8
|
const manifest = await boot.manifest(path, options)
|
|
11
9
|
const component = await boot.component(manifest)
|
|
12
10
|
|
|
@@ -17,7 +15,4 @@ const component = async (path, options) => {
|
|
|
17
15
|
return component
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
const binding = require.resolve('./binding')
|
|
21
|
-
const DEFAULTS = { bindings: [binding] }
|
|
22
|
-
|
|
23
18
|
exports.component = component
|
package/stage/src/composition.js
CHANGED
|
@@ -3,12 +3,8 @@
|
|
|
3
3
|
const boot = require('@toa.io/boot')
|
|
4
4
|
const { state } = require('./state')
|
|
5
5
|
|
|
6
|
-
const binding = require.resolve('./binding')
|
|
7
|
-
|
|
8
6
|
/** @type {toa.stage.Composition} */
|
|
9
7
|
const composition = async (paths, options) => {
|
|
10
|
-
options ??= { bindings: [binding] }
|
|
11
|
-
|
|
12
8
|
const composition = await boot.composition(paths, options)
|
|
13
9
|
|
|
14
10
|
await composition.connect()
|
package/stage/src/index.js
CHANGED
|
@@ -6,7 +6,6 @@ const { composition } = require('./composition')
|
|
|
6
6
|
const { service } = require('./service')
|
|
7
7
|
const { remote } = require('./remote')
|
|
8
8
|
const { shutdown } = require('./shutdown')
|
|
9
|
-
const binding = require('./binding')
|
|
10
9
|
|
|
11
10
|
exports.manifest = manifest
|
|
12
11
|
exports.component = component
|
|
@@ -15,4 +14,3 @@ exports.compose = composition
|
|
|
15
14
|
exports.serve = service
|
|
16
15
|
exports.remote = remote
|
|
17
16
|
exports.shutdown = shutdown
|
|
18
|
-
exports.binding = binding
|
package/stage/src/shutdown.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { state } = require('./state')
|
|
4
|
-
const { binding } = require('./binding')
|
|
5
4
|
|
|
6
5
|
/** @type {toa.stage.Shutdown} */
|
|
7
6
|
const shutdown = async () => {
|
|
@@ -14,7 +13,6 @@ const shutdown = async () => {
|
|
|
14
13
|
await Promise.all(disconnections)
|
|
15
14
|
|
|
16
15
|
state.reset()
|
|
17
|
-
binding.reset()
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
exports.shutdown = shutdown
|
|
@@ -25,14 +25,3 @@ it('should boot composition', async () => {
|
|
|
25
25
|
|
|
26
26
|
expect(composition.connect).toHaveBeenCalled()
|
|
27
27
|
})
|
|
28
|
-
|
|
29
|
-
it('should override bindings', async () => {
|
|
30
|
-
await stage.composition(paths)
|
|
31
|
-
|
|
32
|
-
const path = require.resolve('../src/binding')
|
|
33
|
-
|
|
34
|
-
/** @type {toa.boot.composition.Options} */
|
|
35
|
-
const options = { bindings: [path] }
|
|
36
|
-
|
|
37
|
-
expect(mock.boot.composition.mock.calls[0][1]).toStrictEqual(options)
|
|
38
|
-
})
|
|
@@ -4,16 +4,13 @@ const { generate } = require('randomstring')
|
|
|
4
4
|
|
|
5
5
|
const mock = {
|
|
6
6
|
boot: require('./boot.mock'),
|
|
7
|
-
state: require('./state.mock')
|
|
8
|
-
binding: require('./binding.mock')
|
|
7
|
+
state: require('./state.mock')
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
jest.mock('@toa.io/boot', () => mock.boot)
|
|
12
11
|
jest.mock('../src/state', () => mock.state)
|
|
13
|
-
jest.mock('../src/binding', () => mock.binding)
|
|
14
12
|
|
|
15
13
|
const { state } = require('../src/state')
|
|
16
|
-
const { binding } = require('../src/binding')
|
|
17
14
|
const stage = require('../')
|
|
18
15
|
|
|
19
16
|
beforeEach(() => {
|
|
@@ -58,9 +55,3 @@ it('should reset state', async () => {
|
|
|
58
55
|
|
|
59
56
|
expect(state.reset).toHaveBeenCalled()
|
|
60
57
|
})
|
|
61
|
-
|
|
62
|
-
it('should reset binding', async () => {
|
|
63
|
-
await stage.shutdown()
|
|
64
|
-
|
|
65
|
-
expect(binding.reset).toHaveBeenCalled()
|
|
66
|
-
})
|
package/stage/types/index.d.ts
CHANGED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
title: Should increment number
|
|
2
|
-
input:
|
|
3
|
-
value: 1
|
|
4
|
-
times: 1
|
|
5
|
-
output: 2
|
|
6
|
-
local:
|
|
7
|
-
add:
|
|
8
|
-
input:
|
|
9
|
-
a: 1
|
|
10
|
-
b: 1
|
|
11
|
-
output: 2
|
|
12
|
-
---
|
|
13
|
-
title: Should increment twice
|
|
14
|
-
input:
|
|
15
|
-
value: 0
|
|
16
|
-
times: 2
|
|
17
|
-
output: 2
|
|
18
|
-
local:
|
|
19
|
-
add:
|
|
20
|
-
- input:
|
|
21
|
-
a: 0
|
|
22
|
-
b: 1
|
|
23
|
-
output: 1
|
|
24
|
-
- input:
|
|
25
|
-
a: 1
|
|
26
|
-
b: 1
|
|
27
|
-
output: 2
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
title: Should create
|
|
2
|
-
input:
|
|
3
|
-
material: glass
|
|
4
|
-
volume: 1.5
|
|
5
|
-
next:
|
|
6
|
-
material: glass
|
|
7
|
-
volume: 1.5
|
|
8
|
-
---
|
|
9
|
-
title: Should update
|
|
10
|
-
input:
|
|
11
|
-
material: steel
|
|
12
|
-
current:
|
|
13
|
-
material: glass
|
|
14
|
-
volume: 1.5
|
|
15
|
-
next:
|
|
16
|
-
material: steel
|
|
17
|
-
volume: 1.5
|
|
18
|
-
---
|
|
19
|
-
title: Should emit `created` event
|
|
20
|
-
input:
|
|
21
|
-
material: glass
|
|
22
|
-
volume: 1.5
|
|
23
|
-
next:
|
|
24
|
-
material: glass
|
|
25
|
-
volume: 1.5
|
|
26
|
-
events:
|
|
27
|
-
created:
|
|
28
|
-
material: glass
|
|
29
|
-
volume: 1.5
|
|
30
|
-
---
|
|
31
|
-
title: Should emit `updated` event
|
|
32
|
-
input:
|
|
33
|
-
material: steel
|
|
34
|
-
current:
|
|
35
|
-
material: glass
|
|
36
|
-
volume: 1.5
|
|
37
|
-
next:
|
|
38
|
-
material: steel
|
|
39
|
-
volume: 1.5
|
|
40
|
-
events:
|
|
41
|
-
updated:
|
|
42
|
-
material: steel
|
|
43
|
-
volume: 1.5
|
|
Binary file
|
|
Binary file
|
package/samples/notes.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Developer notes
|
|
2
|
-
|
|
3
|
-
## Extending Replay
|
|
4
|
-
|
|
5
|
-
1. Update [`example`](../example). `toa replay` should either fail or throw exception.
|
|
6
|
-
2. Add [feature](/features). It should fail.
|
|
7
|
-
3. If the new decorator is being developed:
|
|
8
|
-
1. Add the [decorator](/extensions/sampling/docs/replay.md).
|
|
9
|
-
2. Add [boot extension](/runtime/boot/src/extensions).
|
|
10
|
-
4. Update `suite` [translation](./src/.suite/.component/translate.js).
|
|
11
|
-
5. Ensure the feature is passing.
|
|
12
|
-
6. Ensure example is passing with `toa replay`.
|
package/samples/package.json
DELETED
package/samples/readme.md
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Samples
|
|
2
|
-
|
|
3
|
-
## TL;DR
|
|
4
|
-
|
|
5
|
-
<a href="https://miro.com/app/board/uXjVOoy0ImU=/?moveToWidget=3458764532091744292&cot=14">
|
|
6
|
-
<picture>
|
|
7
|
-
<source media="(prefers-color-scheme: dark)" srcset="./docs/sampling-dark.jpg">
|
|
8
|
-
<img alt="4D" width="640" height="435" src="./docs/sampling-light.jpg">
|
|
9
|
-
</picture>
|
|
10
|
-
</a>
|
|
11
|
-
|
|
12
|
-
See [features](/features/replay).
|
|
13
|
-
|
|
14
|
-
## Operation Samples
|
|
15
|
-
|
|
16
|
-
Sample is an object containing values of operation inputs (i.e.: request, context outputs and
|
|
17
|
-
current state) to be substituted and outcomes (reply, context calls, next state and events emission)
|
|
18
|
-
to be verified. See its [schema](./src/.replay/.suite/translate/schemas/operation.cos.yaml).
|
|
19
|
-
|
|
20
|
-
> Although `input` and `output` are declared as arbitrary values, they must conform to the
|
|
21
|
-
> corresponding operation schemas.
|
|
22
|
-
|
|
23
|
-
### Declaration
|
|
24
|
-
|
|
25
|
-
> Samples must be declared
|
|
26
|
-
> as [multi-document YAML files](https://yaml.org/spec/1.2.2/#22-structures).
|
|
27
|
-
|
|
28
|
-
Operation samples must be located under the `samples` directory in the component or context root.
|
|
29
|
-
Sample file names must follow the convention: `namespace.component.operation.yaml`, that is, be an
|
|
30
|
-
endpoint of the operation samples to be applied to. For component-level sample files `namespace`
|
|
31
|
-
and `name` must match corresponding component, therefore are optional.
|
|
32
|
-
|
|
33
|
-
## Message Samples
|
|
34
|
-
|
|
35
|
-
Message Sample is an object containing receiver's input (`payload`) to be substituted and
|
|
36
|
-
outcomes (`input` and `query`) to be verified. Message sample may contain the corresponding
|
|
37
|
-
operation
|
|
38
|
-
sample. See its [schema](./src/.replay/.suite/translate/schemas/message.cos.yaml).
|
|
39
|
-
|
|
40
|
-
> Message samples are only supported at [context level](#autonomy).
|
|
41
|
-
|
|
42
|
-
### Declaration
|
|
43
|
-
|
|
44
|
-
Operation samples must be located under the `samples/messages` directory in the component or context
|
|
45
|
-
root. Samples file names must follow the convention `namesace.component.event.yaml`, that is, be a
|
|
46
|
-
label of the event receiver is consuming.
|
|
47
|
-
|
|
48
|
-
#### Aspect Shortcuts
|
|
49
|
-
|
|
50
|
-
- `configuration` for [Configuration](/extensions/configuration)
|
|
51
|
-
- `state` for [State](/extensions/state)
|
|
52
|
-
- `http` for HTTP Aspect from [Origins](/extensions/origins)
|
|
53
|
-
|
|
54
|
-
#### Aspect Result Type Hints
|
|
55
|
-
|
|
56
|
-
When using aspect calls, there might be situations where the returned values cannot be adequately
|
|
57
|
-
described using YAML.
|
|
58
|
-
To address this issue, type hints can be used.
|
|
59
|
-
|
|
60
|
-
```yaml
|
|
61
|
-
state:
|
|
62
|
-
values:Map:
|
|
63
|
-
foo: 1
|
|
64
|
-
bar: 2
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
In the code snippet above, the `state` Aspect returns a `values` field of type Map.
|
|
68
|
-
|
|
69
|
-
```yaml
|
|
70
|
-
state:
|
|
71
|
-
values:Set: [foo, bar]
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
`sync` and `async` hints define functions:
|
|
75
|
-
|
|
76
|
-
```yaml
|
|
77
|
-
state:
|
|
78
|
-
get:sync: foo
|
|
79
|
-
request:async: bar
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Autonomy
|
|
83
|
-
|
|
84
|
-
Component level samples are *autonomous*, namely, does not assume actual remote calls as
|
|
85
|
-
replaying of component-level samples will boot only that component. Remote call attempt not declared
|
|
86
|
-
within sample will cause an exception.
|
|
87
|
-
See [examples](../example/components/math.calculations/samples).
|
|
88
|
-
|
|
89
|
-
For context level samples (integration samples), remote calls with non-declared outputs will be
|
|
90
|
-
actually performed. Replaying these samples will boot the composition with all components of the
|
|
91
|
-
context (so as required extensions). See [examples](../example/samples).
|
|
92
|
-
|
|
93
|
-
> Integration samples are more flexible and less sensitive to implementation details.
|
|
94
|
-
|
|
95
|
-
## Replay
|
|
96
|
-
|
|
97
|
-
### CLI
|
|
98
|
-
|
|
99
|
-
Samples may be replayed using [`toa replay`](/runtime/cli/readme.md#replay) command.
|
|
100
|
-
|
|
101
|
-
See [features](/features/cli/replay.feature).
|
|
102
|
-
|
|
103
|
-
### Framework
|
|
104
|
-
|
|
105
|
-
`async components(paths: string[], options?): boolean`
|
|
106
|
-
|
|
107
|
-
Replay component samples.
|
|
108
|
-
|
|
109
|
-
`async components(paths: string[], options?): boolean`
|
|
110
|
-
|
|
111
|
-
Replay context and its components' samples.
|
|
112
|
-
|
|
113
|
-
#### Options
|
|
114
|
-
|
|
115
|
-
<dl>
|
|
116
|
-
<dt><code><strong>id</strong>: string</code></dt>
|
|
117
|
-
<dd>Replay samples for a specified component</dd>
|
|
118
|
-
|
|
119
|
-
<dt><code><strong>integration</strong>: string</code></dt>
|
|
120
|
-
<dd>Replay samples for a specified component only</dd>
|
|
121
|
-
<dd></dd>
|
|
122
|
-
|
|
123
|
-
<dt><code><strong>operation</strong>: string</code></dt>
|
|
124
|
-
<dd>Replay samples for specified operation</dd>
|
|
125
|
-
|
|
126
|
-
<dt><code><strong>title</strong>: string</code></dt>
|
|
127
|
-
<dd>Replay samples with titles matching given regexp</dd>
|
|
128
|
-
|
|
129
|
-
</dl>
|
|
130
|
-
|
|
131
|
-
See [types](types/suite.d.ts).
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const stage = require('@toa.io/userland/stage')
|
|
4
|
-
|
|
5
|
-
const { operation } = require('./operation')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {toa.core.Component} component
|
|
9
|
-
* @param {toa.samples.operations.Set} set
|
|
10
|
-
* @param {boolean} autonomous
|
|
11
|
-
* @returns {Function}
|
|
12
|
-
*/
|
|
13
|
-
const component = (component, set, autonomous) =>
|
|
14
|
-
async (test) => {
|
|
15
|
-
for (const [endpoint, samples] of Object.entries(set)) {
|
|
16
|
-
await test.test(endpoint, operation(component, endpoint, samples, autonomous))
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.component = component
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { binding } = require('@toa.io/userland/stage').binding
|
|
4
|
-
|
|
5
|
-
const translate = require('./translate')
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @param {toa.samples.messages.Set} messages
|
|
9
|
-
* @param {boolean} autonomous
|
|
10
|
-
* @return {Function}
|
|
11
|
-
*/
|
|
12
|
-
const messages = (messages, autonomous) =>
|
|
13
|
-
async (test) => {
|
|
14
|
-
for (const [label, samples] of Object.entries(messages)) {
|
|
15
|
-
await test.test(label, message(label, samples, autonomous))
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {string} label
|
|
21
|
-
* @param {toa.samples.Message[]} samples
|
|
22
|
-
* @param {boolean} autonomous
|
|
23
|
-
* @returns {function}
|
|
24
|
-
*/
|
|
25
|
-
const message = (label, samples, autonomous) =>
|
|
26
|
-
async (test) => {
|
|
27
|
-
let n = 0
|
|
28
|
-
|
|
29
|
-
for (const sample of samples) {
|
|
30
|
-
n++
|
|
31
|
-
|
|
32
|
-
const message = translate.message(sample, autonomous)
|
|
33
|
-
const name = sample.title ?? 'Sample #' + n
|
|
34
|
-
|
|
35
|
-
await test.test(name, async () => binding.emit(label, message))
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.messages = messages
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const translate = require('./translate')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {toa.core.Component} remote
|
|
7
|
-
* @param {string} endpoint
|
|
8
|
-
* @param {toa.samples.Operation[]} samples
|
|
9
|
-
* @param {boolean} autonomous
|
|
10
|
-
* @returns {Function}
|
|
11
|
-
*/
|
|
12
|
-
const operation = (remote, endpoint, samples, autonomous) =>
|
|
13
|
-
async (test) => {
|
|
14
|
-
let n = 0
|
|
15
|
-
|
|
16
|
-
for (const operation of samples) {
|
|
17
|
-
n++
|
|
18
|
-
|
|
19
|
-
const request = translate.operation(operation, autonomous)
|
|
20
|
-
const name = operation.title ?? 'Sample #' + n
|
|
21
|
-
|
|
22
|
-
await test.test(name, async () => await remote.invoke(endpoint, request))
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
test.end()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
exports.operation = operation
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { component } = require('./component')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {toa.samples.suite.Operations} operations
|
|
7
|
-
* @param {Record<string, toa.core.Component>} components
|
|
8
|
-
* @param {boolean} autonomous
|
|
9
|
-
* @return {Function}
|
|
10
|
-
*/
|
|
11
|
-
const operations = (operations, components, autonomous) =>
|
|
12
|
-
async (test) => {
|
|
13
|
-
for (const [id, set] of Object.entries(operations)) {
|
|
14
|
-
const remote = components[id]
|
|
15
|
-
|
|
16
|
-
await test.test(id, component(remote, set, autonomous))
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.operations = operations
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { add, defined } = require('@toa.io/generic')
|
|
4
|
-
const translate = require('../operation')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {toa.samples.Message} declaration
|
|
8
|
-
* @param {boolean} autonomous
|
|
9
|
-
* @returns {toa.sampling.request.Sample}
|
|
10
|
-
*/
|
|
11
|
-
const request = (declaration, autonomous) => {
|
|
12
|
-
const { title, input, query } = declaration
|
|
13
|
-
|
|
14
|
-
/** @type {toa.sampling.request.Sample} */
|
|
15
|
-
const sample = declaration.request === undefined
|
|
16
|
-
? {}
|
|
17
|
-
: translate.operation(declaration.request, autonomous).sample
|
|
18
|
-
|
|
19
|
-
const request = defined({ input, query })
|
|
20
|
-
|
|
21
|
-
/** @type {Partial<toa.sampling.request.Sample>} */
|
|
22
|
-
const patch = { title, autonomous, request }
|
|
23
|
-
|
|
24
|
-
if (declaration.request === undefined) patch.terminate = true
|
|
25
|
-
|
|
26
|
-
add(sample, patch)
|
|
27
|
-
|
|
28
|
-
return sample
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
exports.request = request
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { plain } = require('@toa.io/generic')
|
|
4
|
-
const types = require('./types')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {toa.sampling.request.Extensions} extensions
|
|
8
|
-
*/
|
|
9
|
-
function cast (extensions) {
|
|
10
|
-
for (const calls of Object.values(extensions)) calls.map(resolve)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {toa.sampling.request.extensions.Call} call
|
|
15
|
-
*/
|
|
16
|
-
function resolve (call) {
|
|
17
|
-
if (plain(call.result)) call.result = types.cast(call.result)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.cast = cast
|