Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
71a6c83a
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
71a6c83a
编写于
7月 04, 2017
作者:
S
Sean McGivern
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'gitaly-clean-up-tests' into 'master'
Clean up Gitaly tests See merge request !12526
上级
f7e7e40d
ec35a9e8
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
95 addition
and
144 deletion
+95
-144
lib/gitlab/gitaly_client/ref.rb
lib/gitlab/gitaly_client/ref.rb
+1
-1
spec/lib/gitlab/git/blame_spec.rb
spec/lib/gitlab/git/blame_spec.rb
+3
-0
spec/lib/gitlab/git/branch_spec.rb
spec/lib/gitlab/git/branch_spec.rb
+1
-1
spec/lib/gitlab/git/diff_spec.rb
spec/lib/gitlab/git/diff_spec.rb
+1
-1
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+63
-111
spec/lib/gitlab/gitaly_client/ref_spec.rb
spec/lib/gitlab/gitaly_client/ref_spec.rb
+9
-11
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+8
-19
spec/support/matchers/be_utf8.rb
spec/support/matchers/be_utf8.rb
+9
-0
未找到文件。
lib/gitlab/gitaly_client/ref.rb
浏览文件 @
71a6c83a
...
@@ -34,7 +34,7 @@ module Gitlab
...
@@ -34,7 +34,7 @@ module Gitlab
commit_id:
commit_id
,
commit_id:
commit_id
,
prefix:
ref_prefix
prefix:
ref_prefix
)
)
GitalyClient
.
call
(
@storage
,
:ref
,
:find_ref_name
,
request
).
name
encode!
(
GitalyClient
.
call
(
@storage
,
:ref
,
:find_ref_name
,
request
).
name
.
dup
)
end
end
def
count_tag_names
def
count_tag_names
...
...
spec/lib/gitlab/git/blame_spec.rb
浏览文件 @
71a6c83a
...
@@ -20,6 +20,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
...
@@ -20,6 +20,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
expect
(
data
.
size
).
to
eq
(
95
)
expect
(
data
.
size
).
to
eq
(
95
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"# Contribute to GitLab"
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"# Contribute to GitLab"
)
expect
(
data
.
first
[
:line
]).
to
be_utf8
end
end
end
end
...
@@ -40,6 +41,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
...
@@ -40,6 +41,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"Ä ü"
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"Ä ü"
)
expect
(
data
.
first
[
:line
]).
to
be_utf8
end
end
end
end
...
@@ -61,6 +63,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
...
@@ -61,6 +63,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:line
]).
to
eq
(
" "
)
expect
(
data
.
first
[
:line
]).
to
eq
(
" "
)
expect
(
data
.
first
[
:line
]).
to
be_utf8
end
end
end
end
end
end
spec/lib/gitlab/git/branch_spec.rb
浏览文件 @
71a6c83a
...
@@ -48,7 +48,7 @@ describe Gitlab::Git::Branch, seed_helper: true do
...
@@ -48,7 +48,7 @@ describe Gitlab::Git::Branch, seed_helper: true do
expect
(
Gitlab
::
Git
::
Commit
).
to
receive
(
:decorate
)
expect
(
Gitlab
::
Git
::
Commit
).
to
receive
(
:decorate
)
.
with
(
hash_including
(
attributes
)).
and_call_original
.
with
(
hash_including
(
attributes
)).
and_call_original
expect
(
branch
.
dereferenced_target
.
message
.
encoding
).
to
be
(
Encoding
::
UTF_8
)
expect
(
branch
.
dereferenced_target
.
message
).
to
be_utf8
end
end
end
end
...
...
spec/lib/gitlab/git/diff_spec.rb
浏览文件 @
71a6c83a
...
@@ -180,7 +180,7 @@ EOT
...
@@ -180,7 +180,7 @@ EOT
let
(
:raw_patch
)
{
@raw_diff_hash
[
:diff
].
encode
(
Encoding
::
ASCII_8BIT
)
}
let
(
:raw_patch
)
{
@raw_diff_hash
[
:diff
].
encode
(
Encoding
::
ASCII_8BIT
)
}
it
'encodes diff patch to UTF-8'
do
it
'encodes diff patch to UTF-8'
do
expect
(
diff
.
diff
.
encoding
).
to
eq
(
Encoding
::
UTF_8
)
expect
(
diff
.
diff
).
to
be_utf8
end
end
end
end
end
end
...
...
spec/lib/gitlab/git/repository_spec.rb
浏览文件 @
71a6c83a
...
@@ -27,34 +27,24 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -27,34 +27,24 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'returns UTF-8'
do
it
'returns UTF-8'
do
expect
(
repository
.
root_ref
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
expect
(
repository
.
root_ref
).
to
be_utf8
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
...
@@ -129,37 +119,27 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -129,37 +119,27 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'returns UTF-8'
do
it
'returns UTF-8'
do
expect
(
subject
.
first
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
expect
(
subject
.
first
).
to
be_utf8
end
end
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
...
@@ -173,7 +153,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -173,7 +153,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'returns UTF-8'
do
it
'returns UTF-8'
do
expect
(
subject
.
first
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
expect
(
subject
.
first
).
to
be_utf8
end
end
describe
'#last'
do
describe
'#last'
do
...
@@ -183,31 +163,21 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -183,31 +163,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 +1251,31 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -1281,42 +1251,31 @@ 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
branches
.
each
do
|
branch
|
expect
(
branch
.
name
).
to
be_utf8
after
do
expect
(
branch
.
target
).
to
be_utf8
unless
branch
.
target
.
nil?
Gitlab
::
GitalyClient
.
clear_stubs!
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 +1354,4 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -1395,11 +1354,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
浏览文件 @
71a6c83a
...
@@ -6,17 +6,6 @@ describe Gitlab::GitalyClient::Ref do
...
@@ -6,17 +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
# 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
# example, which will cause an error, so we clean the stubs after each example.
Gitlab
::
GitalyClient
.
clear_stubs!
end
describe
'#branch_names'
do
describe
'#branch_names'
do
it
'sends a find_all_branch_names message'
do
it
'sends a find_all_branch_names message'
do
expect_any_instance_of
(
Gitaly
::
Ref
::
Stub
)
expect_any_instance_of
(
Gitaly
::
Ref
::
Stub
)
...
@@ -82,4 +71,13 @@ describe Gitlab::GitalyClient::Ref do
...
@@ -82,4 +71,13 @@ describe Gitlab::GitalyClient::Ref do
expect
{
client
.
local_branches
(
sort_by:
'invalid_sort'
)
}.
to
raise_error
(
ArgumentError
)
expect
{
client
.
local_branches
(
sort_by:
'invalid_sort'
)
}.
to
raise_error
(
ArgumentError
)
end
end
end
end
describe
'#find_ref_name'
,
seed_helper:
true
do
let
(
:repository
)
{
Gitlab
::
Git
::
Repository
.
new
(
'default'
,
TEST_REPO_PATH
)
}
let
(
:client
)
{
described_class
.
new
(
repository
)
}
subject
{
client
.
find_ref_name
(
SeedRepo
::
Commit
::
ID
,
'refs/heads/master'
)
}
it
{
should
be_utf8
}
it
{
should
eq
(
'refs/heads/master'
)
}
end
end
end
spec/models/environment_spec.rb
浏览文件 @
71a6c83a
...
@@ -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
...
...
spec/support/matchers/be_utf8.rb
0 → 100644
浏览文件 @
71a6c83a
RSpec
::
Matchers
.
define
:be_utf8
do
|
_
|
match
do
|
actual
|
actual
.
is_a?
(
String
)
&&
actual
.
encoding
==
Encoding
.
find
(
'UTF-8'
)
end
description
do
"be a String with encoding UTF-8"
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录