Skip to content

Commit 0ce31d8

Browse files
committed
test: prevent null pointer exception in teardown method for testing
1 parent cc4e827 commit 0ce31d8

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

test/benchmark_mixin.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def setup
1010
end
1111

1212
def teardown
13-
@client.call('FLUSHDB')
13+
@client&.call('FLUSHDB')
1414
wait_for_replication
1515
@client&.close
1616
end
@@ -74,7 +74,7 @@ def bench_pipeline_get
7474
def wait_for_replication
7575
client_side_timeout = TEST_TIMEOUT_SEC + 1.0
7676
server_side_timeout = (TEST_TIMEOUT_SEC * 1000).to_i
77-
@client.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
77+
@client&.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
7878
end
7979
end
8080

@@ -87,7 +87,7 @@ def setup
8787
end
8888

8989
def teardown
90-
@cluster_client.call('FLUSHDB')
90+
@cluster_client&.call('FLUSHDB')
9191
wait_for_replication
9292
@cluster_client&.close
9393
@client&.close
@@ -102,6 +102,6 @@ def new_cluster_client
102102
def wait_for_replication
103103
client_side_timeout = TEST_TIMEOUT_SEC + 1.0
104104
server_side_timeout = (TEST_TIMEOUT_SEC * 1000).to_i
105-
@cluster_client.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
105+
@cluster_client&.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
106106
end
107107
end

test/redis_client/cluster/test_normalized_cmd_name.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def setup
1111
end
1212

1313
def teardown
14-
@subject.clear
14+
@subject&.clear
1515
end
1616

1717
def test_get_by_command

test/redis_client/test_cluster.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def test_compatibility_with_redis_gem
253253
def wait_for_replication
254254
client_side_timeout = TEST_TIMEOUT_SEC + 1.0
255255
server_side_timeout = (TEST_TIMEOUT_SEC * 1000).to_i
256-
@client.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
256+
@client&.blocking_call(client_side_timeout, 'WAIT', TEST_REPLICA_SIZE, server_side_timeout)
257257
end
258258
end
259259

test/test_against_cluster_broken.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def setup
2020
end
2121

2222
def teardown
23-
@client.close
24-
@controller.close
23+
@client&.close
24+
@controller&.close
2525
end
2626

2727
def test_a_replica_is_down

test/test_against_cluster_state.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def setup
1717
end
1818

1919
def teardown
20-
@controller.close
21-
@client.close
20+
@controller&.close
21+
@client&.close
2222
end
2323

2424
def test_the_state_of_cluster_down

test/test_concurrency.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def setup
1313
end
1414

1515
def teardown
16-
@client.close
16+
@client&.close
1717
end
1818

1919
def test_forking

0 commit comments

Comments
 (0)