Commit 3d0d6edd authored by Ian Ynda-Hummel's avatar Ian Ynda-Hummel

Add a test for migrating repos to new repo dir.

parent c4641c52
......@@ -154,6 +154,8 @@ module Pod
@old_repos_dir ||= Pathname.new('~/.cocoapods').expand_path
end
attr_writer :old_repos_dir
# @return [Pathname] the root of the CocoaPods installation where the
# Podfile is located.
#
......
......@@ -25,6 +25,7 @@ module Pod
set_up_test_repo
Command::Setup.any_instance.stubs(:read_only_url).returns(test_repo_path.to_s)
config.repos_dir = SpecHelper.temporary_directory
config.old_repos_dir = SpecHelper.temporary_directory + '..'
end
it "runs with correct parameters" do
......@@ -45,5 +46,26 @@ module Pod
Dir.chdir(config.repos_dir + 'master') { `git remote set-url origin git@github.com:CocoaPods/Specs.git` }
command('setup').url.should == 'git@github.com:CocoaPods/Specs.git'
end
before do
FileUtils.rm_rf(test_repo_path)
set_up_old_test_repo
config.repos_dir = SpecHelper.temporary_directory + 'cocoapods/repos'
config.old_repos_dir = SpecHelper.temporary_directory + 'cocoapods'
end
it "migrates repos from the old directory structure to the new one" do
source = config.old_repos_dir + 'master'
target = config.repos_dir + 'master'
source.should.exist?
target.should.not.exist?
output = run_command('setup')
source.should.not.exist?
target.should.exist?
end
end
end
......@@ -45,7 +45,7 @@ module SpecHelper
repo_path('master')
end
# Sets up a lighweight master repo in `tmp/cocoapods/master` with the
# Sets up a lighweight master repo in `tmp/cocoapods/repos/master` with the
# contents of `spec/fixtures/spec-repos/test_repo`.
#
def set_up_test_repo
......@@ -57,10 +57,26 @@ module SpecHelper
repo_make('master')
end
def test_old_repo_path
repo_path('../master')
end
# Sets up a lighweight master repo in `tmp/cocoapods/master` with the
# contents of `spec/fixtures/spec-repos/test_repo`.
#
def set_up_old_test_repo
require 'fileutils'
test_old_repo_path.mkpath
origin = ROOT + 'spec/fixtures/spec-repos/test_repo/.'
destination = tmp_repos_path + '../master'
FileUtils.cp_r(origin, destination)
repo_make('../master')
end
#--------------------------------------#
def tmp_repos_path
SpecHelper.temporary_directory + 'cocoapods/master'
SpecHelper.temporary_directory + 'cocoapods/repos'
end
module_function :tmp_repos_path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment