Skip to content

Commit

Permalink
Test resolve_test_tap
Browse files Browse the repository at this point in the history
  • Loading branch information
tdsmith committed Jun 29, 2016
1 parent 9b36e83 commit 8cf1191
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Library/Homebrew/test/test_cmd_testbot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require "testing_env"
require "dev-cmd/test-bot"

class TestbotCommandTests < Homebrew::TestCase
def with_environment(partial_env)
old = ENV.to_hash
ENV.update partial_env
begin
yield
ensure
ENV.replace old
end
end

def test_resolve_test_tap
tap = Homebrew.resolve_test_tap
assert_nil tap, "Should return nil if no tap slug provided"

slug = "spam/homebrew-eggs"
url = "https://github.com/#{slug}.git"
environments = [
{ "TRAVIS_REPO_SLUG" => slug },
{ "UPSTREAM_BOT_PARAMS" => "--tap=#{slug}" },
{ "UPSTREAM_BOT_PARAMS" => "--tap=spam/eggs" },
{ "UPSTREAM_GIT_URL" => url },
{ "GIT_URL" => url },
]

predicate = proc do |message|
tap = Homebrew.resolve_test_tap
assert_kind_of Tap, tap, message
assert_equal tap.user, "spam", message
assert_equal tap.repo, "eggs", message
end

environments.each do |pair|
with_environment(pair) do
predicate.call pair.to_s
end
end

ARGV.expects(:value).with("tap").returns(slug)
predicate.call "ARGV"
end
end

0 comments on commit 8cf1191

Please sign in to comment.