BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7648f113
Commit
7648f113
authored
Jun 28, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unnecessary contexts
parent
81dba76b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
131 deletions
+74
-131
repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+66
-108
ref_spec.rb
spec/lib/gitlab/gitaly_client/ref_spec.rb
+0
-4
environment_spec.rb
spec/models/environment_spec.rb
+8
-19
No files found.
spec/lib/gitlab/git/repository_spec.rb
View file @
7648f113
...
@@ -5,6 +5,11 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -5,6 +5,11 @@ describe Gitlab::Git::Repository, seed_helper: true do
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
)
}
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
)
}
after
do
# Prevent cached stubs (gRPC connection objects) from poisoning tests.
Gitlab
::
GitalyClient
.
clear_stubs!
end
describe
"Respond to"
do
describe
"Respond to"
do
subject
{
repository
}
subject
{
repository
}
...
@@ -30,31 +35,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -30,31 +35,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect
(
repository
.
root_ref
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
expect
(
repository
.
root_ref
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
end
end
context
'with gitaly enabled'
do
it
'gets the branch name from GitalyClient'
do
before
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
)
stub_gitaly
repository
.
root_ref
end
end
after
do
Gitlab
::
GitalyClient
.
clear_stubs!
end
it
'gets the branch name from GitalyClient'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
)
repository
.
root_ref
end
it
'wraps GRPC not found'
do
it
'wraps GRPC not found'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
)
.
and_raise
(
GRPC
::
NotFound
)
.
and_raise
(
GRPC
::
NotFound
)
expect
{
repository
.
root_ref
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect
{
repository
.
root_ref
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
end
end
it
'wraps GRPC exceptions'
do
it
'wraps GRPC exceptions'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:default_branch_name
)
.
and_raise
(
GRPC
::
Unknown
)
.
and_raise
(
GRPC
::
Unknown
)
expect
{
repository
.
root_ref
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
expect
{
repository
.
root_ref
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
end
end
end
end
end
...
@@ -135,31 +130,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -135,31 +130,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
it
{
is_expected
.
to
include
(
"master"
)
}
it
{
is_expected
.
to
include
(
"master"
)
}
it
{
is_expected
.
not_to
include
(
"branch-from-space"
)
}
it
{
is_expected
.
not_to
include
(
"branch-from-space"
)
}
context
'with gitaly enabled'
do
it
'gets the branch names from GitalyClient'
do
before
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
)
stub_gitaly
subject
end
end
after
do
Gitlab
::
GitalyClient
.
clear_stubs!
end
it
'gets the branch names from GitalyClient'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
)
subject
end
it
'wraps GRPC not found'
do
it
'wraps GRPC not found'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
)
.
and_raise
(
GRPC
::
NotFound
)
.
and_raise
(
GRPC
::
NotFound
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
end
end
it
'wraps GRPC other exceptions'
do
it
'wraps GRPC other exceptions'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:branch_names
)
.
and_raise
(
GRPC
::
Unknown
)
.
and_raise
(
GRPC
::
Unknown
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
end
end
end
end
end
...
@@ -183,31 +168,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -183,31 +168,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
it
{
is_expected
.
to
include
(
"v1.0.0"
)
}
it
{
is_expected
.
to
include
(
"v1.0.0"
)
}
it
{
is_expected
.
not_to
include
(
"v5.0.0"
)
}
it
{
is_expected
.
not_to
include
(
"v5.0.0"
)
}
context
'with gitaly enabled'
do
it
'gets the tag names from GitalyClient'
do
before
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
)
stub_gitaly
subject
end
end
after
do
Gitlab
::
GitalyClient
.
clear_stubs!
end
it
'gets the tag names from GitalyClient'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
)
subject
end
it
'wraps GRPC not found'
do
it
'wraps GRPC not found'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
)
.
and_raise
(
GRPC
::
NotFound
)
.
and_raise
(
GRPC
::
NotFound
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
end
end
it
'wraps GRPC exceptions'
do
it
'wraps GRPC exceptions'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:tag_names
)
.
and_raise
(
GRPC
::
Unknown
)
.
and_raise
(
GRPC
::
Unknown
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
end
end
end
end
end
...
@@ -1281,42 +1256,32 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -1281,42 +1256,32 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect
(
@repo
.
local_branches
.
any?
{
|
branch
|
branch
.
name
==
'local_branch'
}).
to
eq
(
true
)
expect
(
@repo
.
local_branches
.
any?
{
|
branch
|
branch
.
name
==
'local_branch'
}).
to
eq
(
true
)
end
end
context
'with gitaly enabled'
do
it
'returns a Branch with UTF-8 fields'
do
before
do
branches
=
@repo
.
local_branches
.
to_a
stub_gitaly
expect
(
branches
.
size
).
to
be
>
0
end
utf_8
=
Encoding
.
find
(
'utf-8'
)
branches
.
each
do
|
branch
|
after
do
expect
(
branch
.
name
.
encoding
).
to
eq
(
utf_8
)
Gitlab
::
GitalyClient
.
clear_stubs!
expect
(
branch
.
target
.
encoding
).
to
eq
(
utf_8
)
unless
branch
.
target
.
nil?
end
it
'returns a Branch with UTF-8 fields'
do
branches
=
@repo
.
local_branches
.
to_a
expect
(
branches
.
size
).
to
be
>
0
utf_8
=
Encoding
.
find
(
'utf-8'
)
branches
.
each
do
|
branch
|
expect
(
branch
.
name
.
encoding
).
to
eq
(
utf_8
)
expect
(
branch
.
target
.
encoding
).
to
eq
(
utf_8
)
unless
branch
.
target
.
nil?
end
end
end
end
it
'gets the branches from GitalyClient'
do
it
'gets the branches from GitalyClient'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:local_branches
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:local_branches
)
.
and_return
([])
.
and_return
([])
@repo
.
local_branches
@repo
.
local_branches
end
end
it
'wraps GRPC not found'
do
it
'wraps GRPC not found'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:local_branches
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:local_branches
)
.
and_raise
(
GRPC
::
NotFound
)
.
and_raise
(
GRPC
::
NotFound
)
expect
{
@repo
.
local_branches
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
expect
{
@repo
.
local_branches
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
NoRepository
)
end
end
it
'wraps GRPC exceptions'
do
it
'wraps GRPC exceptions'
do
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:local_branches
)
expect_any_instance_of
(
Gitlab
::
GitalyClient
::
Ref
).
to
receive
(
:local_branches
)
.
and_raise
(
GRPC
::
Unknown
)
.
and_raise
(
GRPC
::
Unknown
)
expect
{
@repo
.
local_branches
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
expect
{
@repo
.
local_branches
}.
to
raise_error
(
Gitlab
::
Git
::
CommandError
)
end
end
end
end
end
...
@@ -1395,11 +1360,4 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -1395,11 +1360,4 @@ describe Gitlab::Git::Repository, seed_helper: true do
sha
=
Rugged
::
Commit
.
create
(
repo
,
options
)
sha
=
Rugged
::
Commit
.
create
(
repo
,
options
)
repo
.
lookup
(
sha
)
repo
.
lookup
(
sha
)
end
end
def
stub_gitaly
allow
(
Gitlab
::
GitalyClient
).
to
receive
(
:feature_enabled?
).
and_return
(
true
)
stub
=
double
(
:stub
)
allow
(
Gitaly
::
Ref
::
Stub
).
to
receive
(
:new
).
and_return
(
stub
)
end
end
end
spec/lib/gitlab/gitaly_client/ref_spec.rb
View file @
7648f113
...
@@ -6,10 +6,6 @@ describe Gitlab::GitalyClient::Ref do
...
@@ -6,10 +6,6 @@ describe Gitlab::GitalyClient::Ref do
let
(
:relative_path
)
{
project
.
path_with_namespace
+
'.git'
}
let
(
:relative_path
)
{
project
.
path_with_namespace
+
'.git'
}
let
(
:client
)
{
described_class
.
new
(
project
.
repository
)
}
let
(
:client
)
{
described_class
.
new
(
project
.
repository
)
}
before
do
allow
(
Gitlab
.
config
.
gitaly
).
to
receive
(
:enabled
).
and_return
(
true
)
end
after
do
after
do
# When we say `expect_any_instance_of(Gitaly::Ref::Stub)` a double is created,
# When we say `expect_any_instance_of(Gitaly::Ref::Stub)` a double is created,
# and because GitalyClient shares stubs these will get passed from example to
# and because GitalyClient shares stubs these will get passed from example to
...
...
spec/models/environment_spec.rb
View file @
7648f113
...
@@ -120,28 +120,17 @@ describe Environment, models: true do
...
@@ -120,28 +120,17 @@ describe Environment, models: true do
let
(
:head_commit
)
{
project
.
commit
}
let
(
:head_commit
)
{
project
.
commit
}
let
(
:commit
)
{
project
.
commit
.
parent
}
let
(
:commit
)
{
project
.
commit
.
parent
}
context
'Gitaly find_ref_name feature disabled'
do
it
'returns deployment id for the environment'
do
it
'returns deployment id for the environment'
do
expect
(
environment
.
first_deployment_for
(
commit
)).
to
eq
deployment1
expect
(
environment
.
first_deployment_for
(
commit
)).
to
eq
deployment1
end
end
it
'return nil when no deployment is found'
do
it
'return nil when no deployment is found'
do
expect
(
environment
.
first_deployment_for
(
head_commit
)).
to
eq
nil
expect
(
environment
.
first_deployment_for
(
head_commit
)).
to
eq
nil
end
end
end
# TODO: Uncomment when feature is reenabled
it
'returns a UTF-8 ref'
do
# context 'Gitaly find_ref_name feature enabled' do
expect
(
environment
.
first_deployment_for
(
commit
).
ref
).
to
be_utf8
# before do
end
# allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:find_ref_name).and_return(true)
# end
#
# it 'calls GitalyClient' do
# expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:find_ref_name)
#
# environment.first_deployment_for(commit)
# end
# end
end
end
describe
'#environment_type'
do
describe
'#environment_type'
do
...
...
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