diff options
author | Stan Hu <stanhu@gmail.com> | 2016-05-09 00:21:10 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-05-12 07:00:19 -0500 |
commit | 7f7359b1381d376b81fd9b81120d8cfa0231a526 (patch) | |
tree | bec8110ed8c14fb0dc38ced1ebf21177dbc2acc5 /spec/gitlab_net_spec.rb | |
parent | f0f1bbec8ad5d5fade7c0efeee22ba9b9bc44f07 (diff) | |
download | gitlab-shell-7f7359b1381d376b81fd9b81120d8cfa0231a526.tar.gz |
Use Redis Ruby client instead of shelling out to redis-cli
Closes gitlab-org/gitlab-ce#17329
Diffstat (limited to 'spec/gitlab_net_spec.rb')
-rw-r--r-- | spec/gitlab_net_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb index e4dee33..1312554 100644 --- a/spec/gitlab_net_spec.rb +++ b/spec/gitlab_net_spec.rb @@ -229,4 +229,44 @@ describe GitlabNet, vcr: true do store.should_receive(:add_path).with('test_path') end end + + describe '#redis_client' do + let(:config) { double('config') } + + context "with empty redis config" do + it 'returns default parameters' do + allow(gitlab_net).to receive(:config).and_return(config) + allow(config).to receive(:redis).and_return( {} ) + + expect_any_instance_of(Redis).to receive(:initialize).with({ host: '127.0.0.1', + port: 6379, + db: 0 }).and_call_original + gitlab_net.redis_client + end + end + + context "with host and port" do + it 'uses the specified host and port' do + allow(gitlab_net).to receive(:config).and_return(config) + allow(config).to receive(:redis).and_return( { 'host' => 'localhost', 'port' => 1123 } ) + + expect_any_instance_of(Redis).to receive(:initialize).with({ host: 'localhost', + port: 1123, + db: 0 }).and_call_original + gitlab_net.redis_client + end + end + + context "with redis socket" do + let(:socket) { '/tmp/redis.socket' } + + it 'uses the socket' do + allow(gitlab_net).to receive(:config).and_return(config) + allow(config).to receive(:redis).and_return( { 'socket' => socket }) + + expect_any_instance_of(Redis).to receive(:initialize).with({ path: socket, db: 0 }).and_call_original + gitlab_net.redis_client + end + end + end end |