forked from Homebrew/brew
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |