@@ -4,90 +4,116 @@ module FailureRaisingBehavior
4
4
def test_fetch_read_failure_raises
5
5
@cache . write ( "foo" , "bar" )
6
6
7
- emulating_unavailability do |cache |
8
- cache . fetch ( "foo" )
7
+ assert_raise Redis ::BaseError do
8
+ emulating_unavailability do |cache |
9
+ cache . fetch ( "foo" )
10
+ end
9
11
end
10
12
end
11
13
12
14
def test_fetch_with_block_read_failure_raises
13
15
@cache . write ( "foo" , "bar" )
14
16
15
- emulating_unavailability do |cache |
16
- cache . fetch ( "foo" ) { '1' }
17
+ assert_raise Redis ::BaseError do
18
+ emulating_unavailability do |cache |
19
+ cache . fetch ( "foo" ) { "1" }
20
+ end
17
21
end
22
+
23
+ assert_equal "bar" , @cache . read ( "foo" )
18
24
end
19
25
20
26
def test_read_failure_raises
21
27
@cache . write ( "foo" , "bar" )
22
28
23
- emulating_unavailability do |cache |
24
- cache . read ( "foo" )
29
+ assert_raise Redis ::BaseError do
30
+ emulating_unavailability do |cache |
31
+ cache . read ( "foo" )
32
+ end
25
33
end
26
34
end
27
35
28
36
def test_read_multi_failure_raises
29
37
@cache . write_multi ( "foo" => "bar" , "baz" => "quux" )
30
38
31
- emulating_unavailability do |cache |
32
- cache . read_multi ( "foo" , "baz" )
39
+ assert_raise Redis ::BaseError do
40
+ emulating_unavailability do |cache |
41
+ cache . read_multi ( "foo" , "baz" )
42
+ end
33
43
end
34
44
end
35
45
36
46
def test_write_failure_raises
37
- emulating_unavailability do |cache |
38
- cache . write ( "foo" , "bar" )
47
+ assert_raise Redis ::BaseError do
48
+ emulating_unavailability do |cache |
49
+ cache . write ( "foo" , "bar" )
50
+ end
39
51
end
40
52
end
41
53
42
54
def test_write_multi_failure_raises
43
- emulating_unavailability do |cache |
44
- cache . write_multi ( "foo" => "bar" , "baz" => "quux" )
55
+ assert_raise Redis ::BaseError do
56
+ emulating_unavailability do |cache |
57
+ cache . write_multi ( "foo" => "bar" , "baz" => "quux" )
58
+ end
45
59
end
46
60
end
47
61
48
62
def test_fetch_multi_failure_raises
49
63
@cache . write_multi ( "foo" => "bar" , "baz" => "quux" )
50
64
51
- emulating_unavailability do |cache |
52
- cache . fetch_multi ( "foo" , "baz" ) { |k | "unavailable" }
65
+ assert_raise Redis ::BaseError do
66
+ emulating_unavailability do |cache |
67
+ cache . fetch_multi ( "foo" , "baz" ) { |k | "unavailable" }
68
+ end
53
69
end
54
70
end
55
71
56
72
def test_delete_failure_raises
57
73
@cache . write ( "foo" , "bar" )
58
74
59
- emulating_unavailability do |cache |
60
- cache . delete ( "foo" )
75
+ assert_raise Redis ::BaseError do
76
+ emulating_unavailability do |cache |
77
+ cache . delete ( "foo" )
78
+ end
61
79
end
62
80
end
63
81
64
82
def test_exist_failure_raises
65
83
@cache . write ( "foo" , "bar" )
66
84
67
- emulating_unavailability do |cache |
68
- cache . exist? ( "foo" )
85
+ assert_raise Redis ::BaseError do
86
+ emulating_unavailability do |cache |
87
+ cache . exist? ( "foo" )
88
+ end
69
89
end
70
90
end
71
91
72
92
def test_increment_failure_raises
73
93
@cache . write ( "foo" , 1 , raw : true )
74
94
75
- emulating_unavailability do |cache |
76
- cache . increment ( "foo" )
95
+ assert_raise Redis ::BaseError do
96
+ emulating_unavailability do |cache |
97
+ cache . increment ( "foo" )
98
+ end
77
99
end
78
100
end
79
101
80
102
def test_decrement_failure_raises
81
103
@cache . write ( "foo" , 1 , raw : true )
82
104
83
- emulating_unavailability do |cache |
84
- cache . decrement ( "foo" )
105
+ assert_raise Redis ::BaseError do
106
+ emulating_unavailability do |cache |
107
+ cache . decrement ( "foo" )
108
+ end
85
109
end
86
110
end
87
111
88
112
def test_clear_failure_returns_nil
89
- emulating_unavailability do |cache |
90
- assert_nil cache . clear
113
+ assert_raise Redis ::BaseError do
114
+ emulating_unavailability do |cache |
115
+ cache . clear
116
+ end
91
117
end
92
118
end
93
119
end
0 commit comments