@@ -8,10 +8,10 @@ describe DryRunnable do |
||
| 8 | 8 |
|
| 9 | 9 |
def check |
| 10 | 10 |
log "Logging" |
| 11 |
- create_event payload: { test: "foo" }
|
|
| 11 |
+ create_event payload: { 'test' => 'foo' }
|
|
| 12 | 12 |
error "Recording error" |
| 13 |
- create_event payload: { test: "bar" }
|
|
| 14 |
- self.memory = { last_status: "ok" }
|
|
| 13 |
+ create_event payload: { 'test' => 'bar' }
|
|
| 14 |
+ self.memory = { 'last_status' => 'ok' }
|
|
| 15 | 15 |
save! |
| 16 | 16 |
end |
| 17 | 17 |
end |
@@ -24,18 +24,23 @@ describe DryRunnable do |
||
| 24 | 24 |
} |
| 25 | 25 |
end |
| 26 | 26 |
|
| 27 |
+ def counts |
|
| 28 |
+ [users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count] |
|
| 29 |
+ end |
|
| 30 |
+ |
|
| 27 | 31 |
it "traps logging, event emission and memory updating" do |
| 28 | 32 |
results = nil |
| 29 | 33 |
|
| 30 | 34 |
expect {
|
| 31 | 35 |
results = @agent.dry_run! |
| 36 |
+ @agent.reload |
|
| 32 | 37 |
}.not_to change {
|
| 33 |
- [users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count] |
|
| 38 |
+ [@agent.memory, counts] |
|
| 34 | 39 |
} |
| 35 | 40 |
|
| 36 | 41 |
expect(results[:log]).to match(/\AI, .+ INFO -- : Logging\nE, .+ ERROR -- : Recording error\n/) |
| 37 |
- expect(results[:events]).to eq([{ test: 'foo' }, { test: 'bar' }])
|
|
| 38 |
- expect(results[:memory]).to eq({ "last_status" => "ok" })
|
|
| 42 |
+ expect(results[:events]).to eq([{ 'test' => 'foo' }, { 'test' => 'bar' }])
|
|
| 43 |
+ expect(results[:memory]).to eq({ 'last_status' => 'ok' })
|
|
| 39 | 44 |
end |
| 40 | 45 |
|
| 41 | 46 |
it "does not perform dry-run if Agent does not support dry-run" do |
@@ -45,8 +50,9 @@ describe DryRunnable do |
||
| 45 | 50 |
|
| 46 | 51 |
expect {
|
| 47 | 52 |
results = @agent.dry_run! |
| 53 |
+ @agent.reload |
|
| 48 | 54 |
}.not_to change {
|
| 49 |
- [users(:bob).agents.count, users(:bob).events.count, users(:bob).logs.count] |
|
| 55 |
+ [@agent.memory, counts] |
|
| 50 | 56 |
} |
| 51 | 57 |
|
| 52 | 58 |
expect(results[:log]).to match(/\AE, .+ ERROR -- : Exception during dry-run. SandboxedAgent does not support dry-run: /) |