forked from resque/resque
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresque_failure_redis_test.rb
More file actions
42 lines (34 loc) · 1.35 KB
/
resque_failure_redis_test.rb
File metadata and controls
42 lines (34 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'test_helper'
require 'resque/failure/redis'
unless defined?(JSON)
module JSON
class GeneratorError
end
end
end
describe "Resque::Failure::Redis" do
before do
@bad_string = [39, 250, 141, 168, 138, 191, 52, 211, 159, 86, 93, 95, 39].map { |c| c.chr }.join
exception = StandardError.exception(@bad_string)
worker = Resque::Worker.new(:test)
queue = "queue"
payload = { "class" => Object, "args" => 3 }
@redis_backend = Resque::Failure::Redis.new(exception, worker, queue, payload)
end
it 'cleans up bad strings before saving the failure, in order to prevent errors on the resque UI' do
@redis_backend.save
Resque::Failure::Redis.all # should not raise an error
end
it "only shows the backtrace for client code" do
backtrace = ["show", "/lib/resque/job.rb", "hide"]
failure = Resque::Failure::Redis.new(nil, nil, nil, nil)
filtered_backtrace = failure.filter_backtrace(backtrace)
assert_equal ["show"], filtered_backtrace
end
it "shows the whole backtrace when the exception happens before client code is reached" do
backtrace = ["everything", "is", "shown"]
failure = Resque::Failure::Redis.new(nil, nil, nil, nil)
filtered_backtrace = failure.filter_backtrace(backtrace)
assert_equal ["everything", "is", "shown"], filtered_backtrace
end
end