Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Nov 20, 2023
1 parent 0f57f1b commit 8036c1d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/dynflow/serializers/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Serializers
# the {Dynflow::Action}'s #plan method when the plan is executed.
class Abstract

attr_reader :args, :serialized_args, :serialized_kwargs
attr_reader :args, :kwargs, :serialized_args, :serialized_kwargs

# @param args [Array] arguments to be serialized
# @param serialized_args [nil, Array] arguments in their serialized form
Expand Down
2 changes: 1 addition & 1 deletion lib/dynflow/world.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def delay(action_class, delay_options, *args, **kwargs)
delay_with_options(action_class: action_class, args: args, kwargs: kwargs, delay_options: delay_options)
end

def delay_with_options(action_class:, args:, kwargs:, delay_options:, id: nil, caller_action: nil)
def delay_with_options(action_class:, args:, kwargs: {}, delay_options:, id: nil, caller_action: nil)
raise 'No action_class given' if action_class.nil?
execution_plan = ExecutionPlan.new(self, id)
execution_plan.delay(caller_action, action_class, delay_options, *args, **kwargs)
Expand Down
19 changes: 11 additions & 8 deletions test/future_execution_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,29 @@ module FutureExecutionTest

describe 'serializers' do
let(:args) { %w(arg1 arg2) }
let(:serialized_serializer) { Dynflow::Serializers::Noop.new(nil, args) }
let(:deserialized_serializer) { Dynflow::Serializers::Noop.new(args, nil) }
let(:kwargs) { { foo: 'bar' } }
let(:serialized_serializer) { Dynflow::Serializers::Noop.new(nil, args, nil, [['foo', 'bar']]) }
let(:deserialized_serializer) { Dynflow::Serializers::Noop.new(args, nil, kwargs, nil) }
let(:save_and_load) do
->(thing) { MultiJson.load(MultiJson.dump(thing)) }
end

let(:simulated_use) do
lambda do |serializer_class, input|
serializer = serializer_class.new(input)
lambda do |serializer_class, input, kwargs|
serializer = serializer_class.new(input, nil, kwargs)
serializer.perform_serialization!
serialized_args = save_and_load.call(serializer.serialized_args)
serializer = serializer_class.new(nil, serialized_args)
serialized_kwargs = save_and_load.call(serializer.serialized_kwargs)
serializer = serializer_class.new(nil, serialized_args, nil, serialized_kwargs)
serializer.perform_deserialization!
serializer.args
[serializer.args, serializer.kwargs]
end
end

it 'noop serializer [de]serializes correctly for simple types' do
input = [1, 2.0, 'three', ['four-1', 'four-2'], { 'five' => 5 }]
_(simulated_use.call(Dynflow::Serializers::Noop, input)).must_equal input
kwargs = { foo: 'bar' }
_(simulated_use.call(Dynflow::Serializers::Noop, input, kwargs)).must_equal [input, kwargs]
end

it 'args! raises if not deserialized' do
Expand All @@ -179,7 +182,7 @@ module FutureExecutionTest

describe 'delayed plan' do
let(:args) { %w(arg1 arg2) }
let(:serializer) { Dynflow::Serializers::Noop.new(nil, args) }
let(:serializer) { Dynflow::Serializers::Noop.new(nil, args, nil, []) }
let(:delayed_plan) do
Dynflow::DelayedPlan.new(Dynflow::World.allocate, 'an uuid', nil, nil, serializer, false)
end
Expand Down

0 comments on commit 8036c1d

Please sign in to comment.