trailblazer-activity 0.14.0.beta1 → 0.14.0.beta2
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.
- checksums.yaml +4 -4
- data/CHANGES.md +1 -0
- data/lib/trailblazer/activity/testing.rb +17 -11
- data/lib/trailblazer/activity/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ea76d00d1fbeedcd5160134fff2223300697bd777fb58475fc8de2311c1a5ae
|
|
4
|
+
data.tar.gz: 833e2c3b9fae46af07f07a4422405e1b66606460425d39a8777b84cfed8a0518
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff4c7f7bcd260b495348ba7286e18a60cc104d83ff176d5e82c3c80c22e23bc69cd73cb7976f3637e64b9067932651478b0538b9eaf6731ca793a31ac70e5535
|
|
7
|
+
data.tar.gz: 34c21e990a083a2a08f203f21304b0ad33ab3616450b285f7ddc4c90861c160c5c548e1ea3af92e4a4828df2f789324d21a0deb00aa1e67c07c8084654430c1f
|
data/CHANGES.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* Rename `Activity::State::Config` to `Activity::Config`.
|
|
10
10
|
* Move `VariableMapping` to the `trailblazer-activity-dsl-linear` gem.
|
|
11
11
|
* Move `Pipeline.prepend` to the `trailblazer-activity-linear-dsl` gem.
|
|
12
|
+
* Add `Testing#assert_call` as a consistent test implementation. (0.14.0.beta2)
|
|
12
13
|
|
|
13
14
|
# 0.13.0
|
|
14
15
|
|
|
@@ -54,16 +54,18 @@ module Trailblazer
|
|
|
54
54
|
Schema = Trailblazer::Activity::Schema
|
|
55
55
|
TaskWrap = Trailblazer::Activity::TaskWrap
|
|
56
56
|
|
|
57
|
+
# `:seq` is always passed into ctx.
|
|
57
58
|
# @param :seq String What the {:seq} variable in the result ctx looks like. (expected seq)
|
|
58
|
-
|
|
59
|
+
# @param :expected_ctx_variables Variables that are added during the call by the asserted activity.
|
|
60
|
+
def assert_call(activity, terminus: :success, seq: "[]", expected_ctx_variables: {}, **ctx_variables)
|
|
59
61
|
# Call without taskWrap!
|
|
60
62
|
signal, (ctx, _) = activity.([{seq: [], **ctx_variables}, _flow_options = {}]) # simply call the activity with the input you want to assert.
|
|
61
63
|
|
|
62
|
-
assert_call_for(signal, ctx, terminus: terminus, seq: seq, **ctx_variables)
|
|
64
|
+
assert_call_for(signal, ctx, terminus: terminus, seq: seq, **expected_ctx_variables, **ctx_variables)
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
# Use {TaskWrap.invoke} to call the activity.
|
|
66
|
-
def assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, **ctx_variables) # DISCUSS: only for {activity} gem?
|
|
68
|
+
def assert_invoke(activity, terminus: :success, seq: "[]", circuit_options: {}, expected_ctx_variables: {}, **ctx_variables) # DISCUSS: only for {activity} gem?
|
|
67
69
|
signal, (ctx, _flow_options) = TaskWrap.invoke(
|
|
68
70
|
activity,
|
|
69
71
|
[
|
|
@@ -73,13 +75,15 @@ module Trailblazer
|
|
|
73
75
|
**circuit_options
|
|
74
76
|
)
|
|
75
77
|
|
|
76
|
-
assert_call_for(signal, ctx, terminus: terminus, seq: seq, **ctx_variables)
|
|
78
|
+
assert_call_for(signal, ctx, terminus: terminus, seq: seq, **ctx_variables, **expected_ctx_variables) # DISCUSS: ordering of variables?
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
def assert_call_for(signal, ctx, terminus: :success, seq: "[]", **ctx_variables)
|
|
80
|
-
assert_equal signal.to_h[:semantic], terminus, "assert_call expected #{terminus} terminus, not #{signal}. Use assert_call(activity, terminus: #{signal.to_h[:semantic]})"
|
|
82
|
+
assert_equal signal.to_h[:semantic], terminus, "assert_call expected #{terminus} terminus, not #{signal}. Use assert_call(activity, terminus: #{signal.to_h[:semantic].inspect})"
|
|
81
83
|
|
|
82
84
|
assert_equal ctx.inspect, {seq: "%%%"}.merge(ctx_variables).inspect.sub('"%%%"', seq)
|
|
85
|
+
|
|
86
|
+
return ctx
|
|
83
87
|
end
|
|
84
88
|
|
|
85
89
|
module Implementing
|
|
@@ -95,25 +99,27 @@ module Trailblazer
|
|
|
95
99
|
Implementing
|
|
96
100
|
end
|
|
97
101
|
|
|
98
|
-
def flat_activity
|
|
102
|
+
def flat_activity(implementing: Implementing)
|
|
99
103
|
return @_flat_activity if defined?(@_flat_activity)
|
|
100
104
|
|
|
101
105
|
intermediate = Inter.new(
|
|
102
106
|
{
|
|
103
107
|
Inter::TaskRef("Start.default") => [Inter::Out(:success, :B)],
|
|
104
|
-
Inter::TaskRef(:B, additional: true) => [Inter::Out(:success, :C)],
|
|
108
|
+
Inter::TaskRef(:B, additional: true) => [Inter::Out(:success, :C), Inter::Out(:failure, "End.failure")],
|
|
105
109
|
Inter::TaskRef(:C) => [Inter::Out(:success, "End.success")],
|
|
106
|
-
Inter::TaskRef("End.success", stop_event: true) => [Inter::Out(:success, nil)]
|
|
110
|
+
Inter::TaskRef("End.success", stop_event: true) => [Inter::Out(:success, nil)],
|
|
111
|
+
Inter::TaskRef("End.failure", stop_event: true) => [Inter::Out(:failure, nil)],
|
|
107
112
|
},
|
|
108
|
-
["End.success"],
|
|
113
|
+
["End.success", "End.failure"],
|
|
109
114
|
["Start.default"], # start
|
|
110
115
|
)
|
|
111
116
|
|
|
112
117
|
implementation = {
|
|
113
118
|
"Start.default" => Schema::Implementation::Task(st = Implementing::Start, [Activity::Output(Activity::Right, :success)], []),
|
|
114
|
-
:B => Schema::Implementation::Task(b =
|
|
115
|
-
:C => Schema::Implementation::Task(c =
|
|
119
|
+
:B => Schema::Implementation::Task(b = implementing.method(:b), [Activity::Output(Activity::Right, :success), Activity::Output(Activity::Left, :failure)], []),
|
|
120
|
+
:C => Schema::Implementation::Task(c = implementing.method(:c), [Activity::Output(Activity::Right, :success)], []),
|
|
116
121
|
"End.success" => Schema::Implementation::Task(_es = Implementing::Success, [Activity::Output(Implementing::Success, :success)], []), # DISCUSS: End has one Output, signal is itself?
|
|
122
|
+
"End.failure" => Schema::Implementation::Task(Implementing::Failure, [Activity::Output(Implementing::Failure, :failure)], []), # DISCUSS: End has one Output, signal is itself?
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
schema = Inter.(intermediate, implementation)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trailblazer-activity
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.0.
|
|
4
|
+
version: 0.14.0.beta2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Sutterer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-08-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: trailblazer-context
|