diff options
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/test_tap.rb | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/Library/Homebrew/test/test_tap.rb b/Library/Homebrew/test/test_tap.rb index 278132bad..6438e0808 100644 --- a/Library/Homebrew/test/test_tap.rb +++ b/Library/Homebrew/test/test_tap.rb @@ -1,6 +1,8 @@ require "testing_env" class TapTest < Homebrew::TestCase + include FileUtils + def setup @path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" @path.mkpath @@ -16,7 +18,7 @@ class TapTest < Homebrew::TestCase EOS @alias_file = @path/"Aliases/bar" @alias_file.parent.mkpath - FileUtils.ln_s @formula_file, @alias_file + ln_s @formula_file, @alias_file (@path/"formula_renames.json").write <<-EOS.undent { "oldname": "foo" } EOS @@ -25,14 +27,21 @@ class TapTest < Homebrew::TestCase EOS @cmd_file = @path/"cmd/brew-tap-cmd.rb" @cmd_file.parent.mkpath - FileUtils.touch @cmd_file - FileUtils.chmod 0755, @cmd_file + touch @cmd_file + chmod 0755, @cmd_file @manpage_file = @path/"man/man1/brew-tap-cmd.1" @manpage_file.parent.mkpath - FileUtils.touch @manpage_file + touch @manpage_file end def setup_git_repo + env = ENV.to_hash + %w[AUTHOR COMMITTER].each do |role| + ENV["GIT_#{role}_NAME"] = "brew tests" + ENV["GIT_#{role}_EMAIL"] = "brew-tests@localhost" + ENV["GIT_#{role}_DATE"] = "Thu May 21 00:04:11 2009 +0100" + end + @path.cd do shutup do system "git", "init" @@ -41,6 +50,8 @@ class TapTest < Homebrew::TestCase system "git", "commit", "-m", "init" end end + ensure + ENV.replace(env) end def teardown @@ -74,7 +85,7 @@ class TapTest < Homebrew::TestCase t = Tap.new("someone", "foo") path = Tap::TAP_DIRECTORY/"someone/homebrew-foo" path.mkpath - FileUtils.cd path do + cd path do shutup { system "git", "init" } system "git", "remote", "add", "origin", "https://github.com/someone/homebrew-foo" @@ -123,6 +134,26 @@ class TapTest < Homebrew::TestCase refute_predicate version_tap, :private? end + def test_remote_not_git_repo + assert_nil @tap.remote + end + + def test_remote_git_not_available + setup_git_repo + Utils.stubs(:git_available?).returns(false) + assert_nil @tap.remote + end + + def test_git_variant + touch @path/"README" + setup_git_repo + + assert_equal "e1893a6bd191ba895c71b652ff8376a6114c7fa7", @tap.git_head + assert_equal "e189", @tap.git_short_head + assert_match %r{years ago}, @tap.git_last_commit + assert_equal "2009-05-21", @tap.git_last_commit_date + end + def test_private_remote skip "HOMEBREW_GITHUB_API_TOKEN is required" unless ENV["HOMEBREW_GITHUB_API_TOKEN"] assert_predicate @tap, :private? @@ -174,6 +205,8 @@ class TapTest < Homebrew::TestCase end class CoreFormulaRepositoryTest < Homebrew::TestCase + include FileUtils + def setup @repo = CoreFormulaRepository.new end @@ -204,7 +237,7 @@ class CoreFormulaRepositoryTest < Homebrew::TestCase EOS @alias_file = @repo.alias_dir/"bar" @alias_file.parent.mkpath - FileUtils.ln_s @formula_file, @alias_file + ln_s @formula_file, @alias_file assert_equal [@formula_file], @repo.formula_files assert_equal ["foo"], @repo.formula_names |
