mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-16 03:41:41 +00:00
Make sure DryRunnable does not affect normal run, and test #dry_run? also
This commit is contained in:
parent
316f0bfec6
commit
cc4966daf4
1 changed files with 21 additions and 3 deletions
|
@ -11,7 +11,7 @@ describe DryRunnable do
|
|||
create_event payload: { 'test' => 'foo' }
|
||||
error "Recording error"
|
||||
create_event payload: { 'test' => 'bar' }
|
||||
self.memory = { 'last_status' => 'ok' }
|
||||
self.memory = { 'last_status' => 'ok', 'dry_run' => dry_run? }
|
||||
save!
|
||||
end
|
||||
end
|
||||
|
@ -28,7 +28,25 @@ describe DryRunnable do
|
|||
[users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count]
|
||||
end
|
||||
|
||||
it "traps logging, event emission and memory updating" do
|
||||
it "does not affect normal run, with dry_run? returning false" do
|
||||
before = counts
|
||||
after = before.zip([0, 2, 2]).map { |x, d| x + d }
|
||||
|
||||
expect {
|
||||
@agent.check
|
||||
@agent.reload
|
||||
}.to change { counts }.from(before).to(after)
|
||||
|
||||
expect(@agent.memory).to eq({ 'last_status' => 'ok', 'dry_run' => false })
|
||||
|
||||
payloads = @agent.events.reorder(:id).last(2).map(&:payload)
|
||||
expect(payloads).to eq([{ 'test' => 'foo' }, { 'test' => 'bar' }])
|
||||
|
||||
messages = @agent.logs.reorder(:id).last(2).map(&:message)
|
||||
expect(messages).to eq(['Logging', 'Recording error'])
|
||||
end
|
||||
|
||||
it "traps logging, event emission and memory updating, with dry_run? returning true" do
|
||||
results = nil
|
||||
|
||||
expect {
|
||||
|
@ -40,7 +58,7 @@ describe DryRunnable do
|
|||
|
||||
expect(results[:log]).to match(/\AI, .+ INFO -- : Logging\nE, .+ ERROR -- : Recording error\n/)
|
||||
expect(results[:events]).to eq([{ 'test' => 'foo' }, { 'test' => 'bar' }])
|
||||
expect(results[:memory]).to eq({ 'last_status' => 'ok' })
|
||||
expect(results[:memory]).to eq({ 'last_status' => 'ok', 'dry_run' => true })
|
||||
end
|
||||
|
||||
it "does not perform dry-run if Agent does not support dry-run" do
|
||||
|
|
Loading…
Add table
Reference in a new issue