Skip to content

Commit 1912152

Browse files
committed
chore: Update contract tests to support new hook errors field (#266)
1 parent 8067af6 commit 1912152

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: Run CI
22
on:
33
push:
4-
branches: [ main ]
4+
branches: [ main, 'feat/**' ]
55
paths-ignore:
66
- '**.md' # Do not need to run CI for markdown changes.
77
pull_request:
8-
branches: [ main ]
8+
branches: [ main, 'feat/**' ]
99
paths-ignore:
1010
- '**.md'
1111

contract-tests/client_entity.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def initialize(log, config)
6565

6666
if config[:hooks]
6767
opts[:hooks] = config[:hooks][:hooks].map do |hook|
68-
Hook.new(hook[:name], hook[:callbackUri], hook[:data] || {})
68+
Hook.new(hook[:name], hook[:callbackUri], hook[:data] || {}, hook[:errors] || {})
6969
end
7070
end
7171

contract-tests/hook.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ class Hook
77
# @param name [String]
88
# @param callback_uri [String]
99
# @param data [Hash]
10+
# @parm errors [Hash]
1011
#
11-
def initialize(name, callback_uri, data)
12+
def initialize(name, callback_uri, data, errors)
1213
@metadata = LaunchDarkly::Interfaces::Hooks::Metadata.new(name)
1314
@callback_uri = callback_uri
1415
@data = data
16+
@errors = errors
1517
@context_filter = LaunchDarkly::Impl::ContextFilter.new(false, [])
1618
end
1719

@@ -24,6 +26,8 @@ def metadata
2426
# @param data [Hash]
2527
#
2628
def before_evaluation(evaluation_series_context, data)
29+
raise @errors[:beforeEvaluation] if @errors.include? :beforeEvaluation
30+
2731
payload = {
2832
evaluationSeriesContext: {
2933
flagKey: evaluation_series_context.key,
@@ -46,6 +50,8 @@ def before_evaluation(evaluation_series_context, data)
4650
# @param detail [LaunchDarkly::EvaluationDetail]
4751
#
4852
def after_evaluation(evaluation_series_context, data, detail)
53+
raise @errors[:afterEvaluation] if @errors.include? :afterEvaluation
54+
4955
payload = {
5056
evaluationSeriesContext: {
5157
flagKey: evaluation_series_context.key,

0 commit comments

Comments
 (0)