Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/temporal/testing/local_workflow_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def logger
Temporal.logger
end

def replay?
# We never replay in a test context
false
end

def headers
metadata.headers
end
Expand Down
6 changes: 5 additions & 1 deletion lib/temporal/workflow/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ def initialize(state_manager, dispatcher, metadata)

def logger
@logger ||= ReplayAwareLogger.new(Temporal.logger)
@logger.replay = state_manager.replay?
@logger.replay = replay?
@logger
end

def replay?
@state_manager.replay?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@state_manager.replay?
state_manager.replay?

end

def headers
metadata.headers
end
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/lib/temporal/testing/local_workflow_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,10 @@ def execute
expect(result).to eq('ok')
end
end

describe '#replay?' do
it 'always false' do
expect(workflow_context.replay?).to be false
end
end
end
20 changes: 20 additions & 0 deletions spec/unit/lib/temporal/workflow/context_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'temporal/workflow/context'

describe Temporal::Workflow::Context do
let(:state_manager) { instance_double('Temporal::Workflow::StateManager') }
let(:workflow_context) do
Temporal::Workflow::Context.new(
state_manager,
nil,
nil
)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline before describe

describe '#replay' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
describe '#replay' do
describe '#replay?' do

it 'gets value from state_manager' do
allow(state_manager).to receive(:replay?).and_return true

expect(workflow_context.replay?).to be true
expect(state_manager).to have_received(:replay?)
end
end
end