summaryrefslogtreecommitdiff
path: root/spec/gitlab_projects_spec.rb
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2016-07-19 17:22:13 -0400
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-07-27 11:13:19 -0400
commit522567afca91f2e04871e3d9bf8e9884f48a9855 (patch)
tree6dde32311a141eb97634c801397052541514ae2b /spec/gitlab_projects_spec.rb
parent87b388232505b1715a1d7448dc393a383cd7a53f (diff)
downloadgitlab-shell-522567afca91f2e04871e3d9bf8e9884f48a9855.tar.gz
Add command to move repositories between repository storages
Diffstat (limited to 'spec/gitlab_projects_spec.rb')
-rw-r--r--spec/gitlab_projects_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb
index a06b4d6..5e50af0 100644
--- a/spec/gitlab_projects_spec.rb
+++ b/spec/gitlab_projects_spec.rb
@@ -205,6 +205,43 @@ describe GitlabProjects do
end
end
+ describe :mv_storage do
+ let(:alternative_storage_path) { File.join(ROOT_PATH, 'tmp', 'alternative') }
+ let(:gl_projects) { build_gitlab_projects('mv-storage', tmp_repos_path, repo_name, alternative_storage_path) }
+ let(:new_repo_path) { File.join(alternative_storage_path, repo_name) }
+
+ before do
+ FileUtils.mkdir_p(tmp_repo_path)
+ FileUtils.mkdir_p(alternative_storage_path)
+ end
+
+ after { FileUtils.rm_rf(alternative_storage_path) }
+
+ it "should rsync a repo directory" do
+ File.exists?(tmp_repo_path).should be_true
+ gl_projects.exec
+ File.exists?(new_repo_path).should be_true
+ end
+
+ it "should fail if no destination path is provided" do
+ incomplete = build_gitlab_projects('mv-storage', tmp_repos_path, repo_name)
+ $logger.should_receive(:error).with("mv-storage failed: no destination storage path provided.")
+ incomplete.exec.should be_false
+ end
+
+ it "should fail if the source path doesn't exist" do
+ bad_source = build_gitlab_projects('mv-storage', tmp_repos_path, 'bad-src.git', alternative_storage_path)
+ $logger.should_receive(:error).with("mv-storage failed: source path <#{tmp_repos_path}/bad-src.git> does not exist.")
+ bad_source.exec.should be_false
+ end
+
+ it "should log an mv-storage event" do
+ message = "Syncing project #{repo_name} from <#{tmp_repo_path}> to <#{new_repo_path}>."
+ $logger.should_receive(:info).with(message)
+ gl_projects.exec
+ end
+ end
+
describe :import_project do
context 'success import' do
let(:gl_projects) { build_gitlab_projects('import-project', tmp_repos_path, repo_name, 'https://github.com/randx/six.git') }