Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
353d3da4
Commit
353d3da4
authored
Mar 15, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix redis spec
parent
e5ac0644
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
33 deletions
+31
-33
spec/config/mail_room_spec.rb
spec/config/mail_room_spec.rb
+3
-2
spec/lib/gitlab/redis_spec.rb
spec/lib/gitlab/redis_spec.rb
+28
-31
No files found.
spec/config/mail_room_spec.rb
View file @
353d3da4
require
'spec_helper'
require
'spec_helper'
describe
'mail_room.yml'
do
describe
'mail_room.yml'
do
include
StubENV
let
(
:mailroom_config_path
)
{
'config/mail_room.yml'
}
let
(
:mailroom_config_path
)
{
'config/mail_room.yml'
}
let
(
:gitlab_config_path
)
{
'config/mail_room.yml'
}
let
(
:gitlab_config_path
)
{
'config/mail_room.yml'
}
let
(
:redis_config_path
)
{
'config/resque.yml'
}
let
(
:redis_config_path
)
{
'config/resque.yml'
}
...
@@ -19,12 +21,11 @@ describe 'mail_room.yml' do
...
@@ -19,12 +21,11 @@ describe 'mail_room.yml' do
end
end
before
(
:each
)
do
before
(
:each
)
do
ENV
[
'GITLAB_REDIS_CONFIG_FILE'
]
=
absolute_path
(
redis_config_path
)
stub_env
(
'GITLAB_REDIS_CONFIG_FILE'
,
absolute_path
(
redis_config_path
)
)
clear_redis_raw_config
clear_redis_raw_config
end
end
after
(
:each
)
do
after
(
:each
)
do
ENV
[
'GITLAB_REDIS_CONFIG_FILE'
]
=
nil
clear_redis_raw_config
clear_redis_raw_config
end
end
...
...
spec/lib/gitlab/redis_spec.rb
View file @
353d3da4
...
@@ -3,8 +3,16 @@ require 'spec_helper'
...
@@ -3,8 +3,16 @@ require 'spec_helper'
describe
Gitlab
::
Redis
do
describe
Gitlab
::
Redis
do
include
StubENV
include
StubENV
before
(
:each
)
{
clear_raw_config
}
let
(
:config
)
{
'config/resque.yml'
}
after
(
:each
)
{
clear_raw_config
}
before
(
:each
)
do
stub_env
(
'GITLAB_REDIS_CONFIG_FILE'
,
Rails
.
root
.
join
(
config
).
to_s
)
clear_raw_config
end
after
(
:each
)
do
clear_raw_config
end
describe
'.params'
do
describe
'.params'
do
subject
{
described_class
.
params
}
subject
{
described_class
.
params
}
...
@@ -18,22 +26,22 @@ describe Gitlab::Redis do
...
@@ -18,22 +26,22 @@ describe Gitlab::Redis do
end
end
context
'when url contains unix socket reference'
do
context
'when url contains unix socket reference'
do
let
(
:config_old
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_old_format_socket.yml'
).
to_s
}
let
(
:config_old
)
{
'spec/fixtures/config/redis_old_format_socket.yml'
}
let
(
:config_new
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_new_format_socket.yml'
).
to_s
}
let
(
:config_new
)
{
'spec/fixtures/config/redis_new_format_socket.yml'
}
context
'with old format'
do
context
'with old format'
do
it
'returns path key instead'
do
let
(
:config
)
{
config_old
}
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config_old
)
it
'returns path key instead'
do
is_expected
.
to
include
(
path:
'/path/to/old/redis.sock'
)
is_expected
.
to
include
(
path:
'/path/to/old/redis.sock'
)
is_expected
.
not_to
have_key
(
:url
)
is_expected
.
not_to
have_key
(
:url
)
end
end
end
end
context
'with new format'
do
context
'with new format'
do
it
'returns path key instead'
do
let
(
:config
)
{
config_new
}
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config_new
)
it
'returns path key instead'
do
is_expected
.
to
include
(
path:
'/path/to/redis.sock'
)
is_expected
.
to
include
(
path:
'/path/to/redis.sock'
)
is_expected
.
not_to
have_key
(
:url
)
is_expected
.
not_to
have_key
(
:url
)
end
end
...
@@ -41,22 +49,22 @@ describe Gitlab::Redis do
...
@@ -41,22 +49,22 @@ describe Gitlab::Redis do
end
end
context
'when url is host based'
do
context
'when url is host based'
do
let
(
:config_old
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_old_format_host.yml'
)
}
let
(
:config_old
)
{
'spec/fixtures/config/redis_old_format_host.yml'
}
let
(
:config_new
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_new_format_host.yml'
)
}
let
(
:config_new
)
{
'spec/fixtures/config/redis_new_format_host.yml'
}
context
'with old format'
do
context
'with old format'
do
it
'returns hash with host, port, db, and password'
do
let
(
:config
)
{
config_old
}
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config_old
)
it
'returns hash with host, port, db, and password'
do
is_expected
.
to
include
(
host:
'localhost'
,
password:
'mypassword'
,
port:
6379
,
db:
99
)
is_expected
.
to
include
(
host:
'localhost'
,
password:
'mypassword'
,
port:
6379
,
db:
99
)
is_expected
.
not_to
have_key
(
:url
)
is_expected
.
not_to
have_key
(
:url
)
end
end
end
end
context
'with new format'
do
context
'with new format'
do
it
'returns hash with host, port, db, and password'
do
let
(
:config
)
{
config_new
}
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config_new
)
it
'returns hash with host, port, db, and password'
do
is_expected
.
to
include
(
host:
'localhost'
,
password:
'mynewpassword'
,
port:
6379
,
db:
99
)
is_expected
.
to
include
(
host:
'localhost'
,
password:
'mynewpassword'
,
port:
6379
,
db:
99
)
is_expected
.
not_to
have_key
(
:url
)
is_expected
.
not_to
have_key
(
:url
)
end
end
...
@@ -74,15 +82,13 @@ describe Gitlab::Redis do
...
@@ -74,15 +82,13 @@ describe Gitlab::Redis do
end
end
context
'when yml file with env variable'
do
context
'when yml file with env variable'
do
let
(
:
redis_config
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_config_with_env.yml'
)
}
let
(
:
config
)
{
'spec/fixtures/config/redis_config_with_env.yml'
}
before
do
before
do
stub_env
(
'TEST_GITLAB_REDIS_URL'
,
'redis://redishost:6379'
)
stub_env
(
'TEST_GITLAB_REDIS_URL'
,
'redis://redishost:6379'
)
end
end
it
'reads redis url from env variable'
do
it
'reads redis url from env variable'
do
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
redis_config
)
expect
(
described_class
.
url
).
to
eq
'redis://redishost:6379'
expect
(
described_class
.
url
).
to
eq
'redis://redishost:6379'
end
end
end
end
...
@@ -90,14 +96,13 @@ describe Gitlab::Redis do
...
@@ -90,14 +96,13 @@ describe Gitlab::Redis do
describe
'._raw_config'
do
describe
'._raw_config'
do
subject
{
described_class
.
_raw_config
}
subject
{
described_class
.
_raw_config
}
let
(
:config
)
{
'/var/empty/doesnotexist'
}
it
'should be frozen'
do
it
'should be frozen'
do
expect
(
subject
).
to
be_frozen
expect
(
subject
).
to
be_frozen
end
end
it
'returns false when the file does not exist'
do
it
'returns false when the file does not exist'
do
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
'/var/empty/doesnotexist'
)
expect
(
subject
).
to
eq
(
false
)
expect
(
subject
).
to
eq
(
false
)
end
end
end
end
...
@@ -134,22 +139,18 @@ describe Gitlab::Redis do
...
@@ -134,22 +139,18 @@ describe Gitlab::Redis do
subject
{
described_class
.
new
(
Rails
.
env
).
sentinels
}
subject
{
described_class
.
new
(
Rails
.
env
).
sentinels
}
context
'when sentinels are defined'
do
context
'when sentinels are defined'
do
let
(
:config
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_new_format_host.yml'
)
}
let
(
:config
)
{
'spec/fixtures/config/redis_new_format_host.yml'
}
it
'returns an array of hashes with host and port keys'
do
it
'returns an array of hashes with host and port keys'
do
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config
)
is_expected
.
to
include
(
host:
'localhost'
,
port:
26380
)
is_expected
.
to
include
(
host:
'localhost'
,
port:
26380
)
is_expected
.
to
include
(
host:
'slave2'
,
port:
26381
)
is_expected
.
to
include
(
host:
'slave2'
,
port:
26381
)
end
end
end
end
context
'when sentinels are not defined'
do
context
'when sentinels are not defined'
do
let
(
:config
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_old_format_host.yml'
)
}
let
(
:config
)
{
'spec/fixtures/config/redis_old_format_host.yml'
}
it
'returns nil'
do
it
'returns nil'
do
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config
)
is_expected
.
to
be_nil
is_expected
.
to
be_nil
end
end
end
end
...
@@ -159,21 +160,17 @@ describe Gitlab::Redis do
...
@@ -159,21 +160,17 @@ describe Gitlab::Redis do
subject
{
described_class
.
new
(
Rails
.
env
).
sentinels?
}
subject
{
described_class
.
new
(
Rails
.
env
).
sentinels?
}
context
'when sentinels are defined'
do
context
'when sentinels are defined'
do
let
(
:config
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_new_format_host.yml'
)
}
let
(
:config
)
{
'spec/fixtures/config/redis_new_format_host.yml'
}
it
'returns true'
do
it
'returns true'
do
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config
)
is_expected
.
to
be_truthy
is_expected
.
to
be_truthy
end
end
end
end
context
'when sentinels are not defined'
do
context
'when sentinels are not defined'
do
let
(
:config
)
{
Rails
.
root
.
join
(
'spec/fixtures/config/redis_old_format_host.yml'
)
}
let
(
:config
)
{
'spec/fixtures/config/redis_old_format_host.yml'
}
it
'returns false'
do
it
'returns false'
do
stub_const
(
"
#{
described_class
}
::CONFIG_FILE"
,
config
)
is_expected
.
to
be_falsey
is_expected
.
to
be_falsey
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment