Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-shell
Commits
3b37fc72
Commit
3b37fc72
authored
May 17, 2013
by
ash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specs for logging in gitlab_projects.
parent
2a3b15ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletion
+40
-1
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+40
-1
No files found.
spec/gitlab_projects_spec.rb
View file @
3b37fc72
...
@@ -4,6 +4,7 @@ require_relative '../lib/gitlab_projects'
...
@@ -4,6 +4,7 @@ require_relative '../lib/gitlab_projects'
describe
GitlabProjects
do
describe
GitlabProjects
do
before
do
before
do
FileUtils
.
mkdir_p
(
tmp_repos_path
)
FileUtils
.
mkdir_p
(
tmp_repos_path
)
$logger
=
double
(
'logger'
).
as_null_object
end
end
after
do
after
do
...
@@ -37,10 +38,16 @@ describe GitlabProjects do
...
@@ -37,10 +38,16 @@ describe GitlabProjects do
gl_projects
.
should_receive
(
:system
).
with
(
valid_cmd
)
gl_projects
.
should_receive
(
:system
).
with
(
valid_cmd
)
gl_projects
.
exec
gl_projects
.
exec
end
end
it
"should log an add-project event"
do
$logger
.
should_receive
(
:info
).
with
(
"Adding project
#{
repo_name
}
at <
#{
tmp_repo_path
}
>."
)
gl_projects
.
exec
end
end
end
describe
:mv_project
do
describe
:mv_project
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'mv-project'
,
repo_name
,
'repo.git'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'mv-project'
,
repo_name
,
'repo.git'
)
}
let
(
:new_repo_path
)
{
File
.
join
(
tmp_repos_path
,
'repo.git'
)
}
before
do
before
do
FileUtils
.
mkdir_p
(
tmp_repo_path
)
FileUtils
.
mkdir_p
(
tmp_repo_path
)
...
@@ -50,7 +57,13 @@ describe GitlabProjects do
...
@@ -50,7 +57,13 @@ describe GitlabProjects do
File
.
exists?
(
tmp_repo_path
).
should
be_true
File
.
exists?
(
tmp_repo_path
).
should
be_true
gl_projects
.
exec
gl_projects
.
exec
File
.
exists?
(
tmp_repo_path
).
should
be_false
File
.
exists?
(
tmp_repo_path
).
should
be_false
File
.
exists?
(
File
.
join
(
tmp_repos_path
,
'repo.git'
)).
should
be_true
File
.
exists?
(
new_repo_path
).
should
be_true
end
it
"should log an mv-project event"
do
message
=
"Moving project
#{
repo_name
}
from <
#{
tmp_repo_path
}
> to <
#{
new_repo_path
}
>."
$logger
.
should_receive
(
:info
).
with
(
message
)
gl_projects
.
exec
end
end
end
end
...
@@ -66,6 +79,11 @@ describe GitlabProjects do
...
@@ -66,6 +79,11 @@ describe GitlabProjects do
gl_projects
.
exec
gl_projects
.
exec
File
.
exists?
(
tmp_repo_path
).
should
be_false
File
.
exists?
(
tmp_repo_path
).
should
be_false
end
end
it
"should log an rm-project event"
do
$logger
.
should_receive
(
:info
).
with
(
"Removing project
#{
repo_name
}
from <
#{
tmp_repo_path
}
>."
)
gl_projects
.
exec
end
end
end
describe
:import_project
do
describe
:import_project
do
...
@@ -75,6 +93,12 @@ describe GitlabProjects do
...
@@ -75,6 +93,12 @@ describe GitlabProjects do
gl_projects
.
exec
gl_projects
.
exec
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'HEAD'
)).
should
be_true
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'HEAD'
)).
should
be_true
end
end
it
"should log an import-project event"
do
message
=
"Importing project
#{
repo_name
}
from <https://github.com/randx/six.git> to <
#{
tmp_repo_path
}
>."
$logger
.
should_receive
(
:info
).
with
(
message
)
gl_projects
.
exec
end
end
end
describe
:fork_project
do
describe
:fork_project
do
...
@@ -104,6 +128,15 @@ describe GitlabProjects do
...
@@ -104,6 +128,15 @@ describe GitlabProjects do
#trying to fork again should fail as the repo already exists
#trying to fork again should fail as the repo already exists
gl_projects_fork
.
exec
.
should
be_false
gl_projects_fork
.
exec
.
should
be_false
end
end
it
"should log a fork-project event"
do
message
=
"Forking project from <
#{
File
.
join
(
tmp_repos_path
,
source_repo_name
)
}
> to <
#{
dest_repo
}
>."
$logger
.
should_receive
(
:info
).
with
(
message
)
# create destination namespace
FileUtils
.
mkdir_p
(
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
))
gl_projects_fork
.
exec
.
should
be_true
end
end
end
describe
:exec
do
describe
:exec
do
...
@@ -112,6 +145,12 @@ describe GitlabProjects do
...
@@ -112,6 +145,12 @@ describe GitlabProjects do
gitlab_projects
.
should_receive
(
:puts
).
with
(
'not allowed'
)
gitlab_projects
.
should_receive
(
:puts
).
with
(
'not allowed'
)
gitlab_projects
.
exec
gitlab_projects
.
exec
end
end
it
'should log a message for unknown commands'
do
gitlab_projects
=
build_gitlab_projects
(
'hurf-durf'
,
repo_name
)
$logger
.
should_receive
(
:error
).
with
(
'Attempt to execute invalid gitlab-projects command "hurf-durf".'
)
gitlab_projects
.
exec
end
end
end
def
build_gitlab_projects
(
*
args
)
def
build_gitlab_projects
(
*
args
)
...
...
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