| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  | require "testing_env" | 
					
						
							| 
									
										
										
										
											2016-10-24 22:53:25 +02:00
										 |  |  | require "testing_env" | 
					
						
							| 
									
										
										
										
											2016-09-27 00:03:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class IntegrationCommandTestTap < IntegrationCommandTestCase | 
					
						
							|  |  |  |   def test_tap | 
					
						
							|  |  |  |     path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" | 
					
						
							|  |  |  |     path.mkpath | 
					
						
							|  |  |  |     path.cd do | 
					
						
							|  |  |  |       shutup do | 
					
						
							|  |  |  |         system "git", "init" | 
					
						
							|  |  |  |         system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" | 
					
						
							|  |  |  |         FileUtils.touch "readme" | 
					
						
							|  |  |  |         system "git", "add", "--all" | 
					
						
							|  |  |  |         system "git", "commit", "-m", "init" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert_match "homebrew/foo", cmd("tap") | 
					
						
							|  |  |  |     assert_match "homebrew/versions", cmd("tap", "--list-official") | 
					
						
							|  |  |  |     assert_match "2 taps", cmd("tap-info") | 
					
						
							|  |  |  |     assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "homebrew/foo") | 
					
						
							|  |  |  |     assert_match "https://github.com/Homebrew/homebrew-foo", cmd("tap-info", "--json=v1", "--installed") | 
					
						
							|  |  |  |     assert_match "Pinned homebrew/foo", cmd("tap-pin", "homebrew/foo") | 
					
						
							|  |  |  |     assert_match "homebrew/foo", cmd("tap", "--list-pinned") | 
					
						
							|  |  |  |     assert_match "Unpinned homebrew/foo", cmd("tap-unpin", "homebrew/foo") | 
					
						
							|  |  |  |     assert_match "Tapped", cmd("tap", "homebrew/bar", path/".git") | 
					
						
							|  |  |  |     assert_match "Untapped", cmd("untap", "homebrew/bar") | 
					
						
							|  |  |  |     assert_equal "", cmd("tap", "homebrew/bar", path/".git", "-q", "--full") | 
					
						
							|  |  |  |     assert_match "Untapped", cmd("untap", "homebrew/bar") | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | class TapTest < Homebrew::TestCase | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |   include FileUtils | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   def setup | 
					
						
							|  |  |  |     @path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" | 
					
						
							|  |  |  |     @path.mkpath | 
					
						
							|  |  |  |     @tap = Tap.new("Homebrew", "foo") | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setup_tap_files | 
					
						
							|  |  |  |     @formula_file = @path/"Formula/foo.rb" | 
					
						
							|  |  |  |     @formula_file.write <<-EOS.undent
 | 
					
						
							|  |  |  |       class Foo < Formula | 
					
						
							|  |  |  |         url "https://example.com/foo-1.0.tar.gz" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |     @alias_file = @path/"Aliases/bar" | 
					
						
							|  |  |  |     @alias_file.parent.mkpath | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |     ln_s @formula_file, @alias_file | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     (@path/"formula_renames.json").write <<-EOS.undent
 | 
					
						
							|  |  |  |      { "oldname": "foo" } | 
					
						
							|  |  |  |     EOS | 
					
						
							| 
									
										
										
										
											2016-02-25 14:14:33 +08:00
										 |  |  |     (@path/"tap_migrations.json").write <<-EOS.undent
 | 
					
						
							|  |  |  |      { "removed-formula": "homebrew/foo" } | 
					
						
							|  |  |  |     EOS | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     @cmd_file = @path/"cmd/brew-tap-cmd.rb" | 
					
						
							|  |  |  |     @cmd_file.parent.mkpath | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |     touch @cmd_file | 
					
						
							|  |  |  |     chmod 0755, @cmd_file | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     @manpage_file = @path/"man/man1/brew-tap-cmd.1" | 
					
						
							|  |  |  |     @manpage_file.parent.mkpath | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |     touch @manpage_file | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setup_git_repo | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |     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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     @path.cd do | 
					
						
							|  |  |  |       shutup do | 
					
						
							|  |  |  |         system "git", "init" | 
					
						
							|  |  |  |         system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" | 
					
						
							|  |  |  |         system "git", "add", "--all" | 
					
						
							|  |  |  |         system "git", "commit", "-m", "init" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |   ensure | 
					
						
							|  |  |  |     ENV.replace(env) | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def teardown | 
					
						
							| 
									
										
										
										
											2016-02-26 19:43:49 +08:00
										 |  |  |     @path.rmtree | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_fetch | 
					
						
							| 
									
										
										
										
											2016-03-07 18:04:25 +08:00
										 |  |  |     assert_kind_of CoreTap, Tap.fetch("Homebrew", "homebrew") | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     tap = Tap.fetch("Homebrew", "foo") | 
					
						
							|  |  |  |     assert_kind_of Tap, tap | 
					
						
							|  |  |  |     assert_equal "homebrew/foo", tap.name | 
					
						
							| 
									
										
										
										
											2016-07-27 03:08:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     assert_match "Invalid tap name", | 
					
						
							|  |  |  |                  assert_raises { Tap.fetch("foo") }.message | 
					
						
							|  |  |  |     assert_match "Invalid tap name", | 
					
						
							|  |  |  |                  assert_raises { Tap.fetch("homebrew/homebrew/bar") }.message | 
					
						
							|  |  |  |     assert_match "Invalid tap name", | 
					
						
							|  |  |  |                  assert_raises { Tap.fetch("homebrew", "homebrew/baz") }.message | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   ensure | 
					
						
							|  |  |  |     Tap.clear_cache | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_names | 
					
						
							| 
									
										
										
										
											2016-11-08 11:38:59 -08:00
										 |  |  |     assert_equal ["homebrew/core", "homebrew/foo"], Tap.names.sort | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_attributes | 
					
						
							|  |  |  |     assert_equal "Homebrew", @tap.user | 
					
						
							|  |  |  |     assert_equal "foo", @tap.repo | 
					
						
							|  |  |  |     assert_equal "homebrew/foo", @tap.name | 
					
						
							|  |  |  |     assert_equal @path, @tap.path | 
					
						
							|  |  |  |     assert_predicate @tap, :installed? | 
					
						
							|  |  |  |     assert_predicate @tap, :official? | 
					
						
							| 
									
										
										
										
											2016-03-07 18:04:25 +08:00
										 |  |  |     refute_predicate @tap, :core_tap? | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-28 13:23:22 +01:00
										 |  |  |   def test_issues_url | 
					
						
							|  |  |  |     t = Tap.new("someone", "foo") | 
					
						
							|  |  |  |     path = Tap::TAP_DIRECTORY/"someone/homebrew-foo" | 
					
						
							|  |  |  |     path.mkpath | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |     cd path do | 
					
						
							| 
									
										
										
										
											2015-12-28 13:23:22 +01:00
										 |  |  |       shutup { system "git", "init" } | 
					
						
							|  |  |  |       system "git", "remote", "add", "origin", | 
					
						
							|  |  |  |         "https://github.com/someone/homebrew-foo" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     assert_equal "https://github.com/someone/homebrew-foo/issues", t.issues_url | 
					
						
							|  |  |  |     assert_equal "https://github.com/Homebrew/homebrew-foo/issues", @tap.issues_url | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     (Tap::TAP_DIRECTORY/"someone/homebrew-no-git").mkpath | 
					
						
							|  |  |  |     assert_nil Tap.new("someone", "no-git").issues_url | 
					
						
							| 
									
										
										
										
											2016-02-26 19:43:49 +08:00
										 |  |  |   ensure | 
					
						
							|  |  |  |     path.parent.rmtree | 
					
						
							| 
									
										
										
										
											2015-12-28 13:23:22 +01:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   def test_files | 
					
						
							|  |  |  |     setup_tap_files | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert_equal [@formula_file], @tap.formula_files | 
					
						
							|  |  |  |     assert_equal ["homebrew/foo/foo"], @tap.formula_names | 
					
						
							|  |  |  |     assert_equal [@alias_file], @tap.alias_files | 
					
						
							|  |  |  |     assert_equal ["homebrew/foo/bar"], @tap.aliases | 
					
						
							|  |  |  |     assert_equal @tap.alias_table, "homebrew/foo/bar" => "homebrew/foo/foo" | 
					
						
							|  |  |  |     assert_equal @tap.alias_reverse_table, "homebrew/foo/foo" => ["homebrew/foo/bar"] | 
					
						
							|  |  |  |     assert_equal @tap.formula_renames, "oldname" => "foo" | 
					
						
							| 
									
										
										
										
											2016-02-25 14:14:33 +08:00
										 |  |  |     assert_equal @tap.tap_migrations, "removed-formula" => "homebrew/foo" | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     assert_equal [@cmd_file], @tap.command_files | 
					
						
							|  |  |  |     assert_kind_of Hash, @tap.to_hash | 
					
						
							| 
									
										
										
										
											2016-02-15 22:31:47 +08:00
										 |  |  |     assert_equal true, @tap.formula_file?(@formula_file) | 
					
						
							|  |  |  |     assert_equal true, @tap.formula_file?("Formula/foo.rb") | 
					
						
							|  |  |  |     assert_equal false, @tap.formula_file?("bar.rb") | 
					
						
							|  |  |  |     assert_equal false, @tap.formula_file?("Formula/baz.sh") | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_remote | 
					
						
							|  |  |  |     setup_git_repo | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert_equal "https://github.com/Homebrew/homebrew-foo", @tap.remote | 
					
						
							|  |  |  |     assert_raises(TapUnavailableError) { Tap.new("Homebrew", "bar").remote } | 
					
						
							|  |  |  |     refute_predicate @tap, :custom_remote? | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     version_tap = Tap.new("Homebrew", "versions") | 
					
						
							|  |  |  |     version_tap.path.mkpath | 
					
						
							|  |  |  |     version_tap.path.cd do | 
					
						
							|  |  |  |       shutup do | 
					
						
							|  |  |  |         system "git", "init" | 
					
						
							|  |  |  |         system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-versions" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     refute_predicate version_tap, :private? | 
					
						
							| 
									
										
										
										
											2016-02-26 19:43:49 +08:00
										 |  |  |   ensure | 
					
						
							| 
									
										
										
										
											2016-07-09 13:51:19 +01:00
										 |  |  |     version_tap.path.rmtree if version_tap | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |   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 | 
					
						
							| 
									
										
										
										
											2016-08-05 22:04:59 -07:00
										 |  |  |     assert_match "years ago", @tap.git_last_commit | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |     assert_equal "2009-05-21", @tap.git_last_commit_date | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-11 22:07:04 +08:00
										 |  |  |   def test_private_remote | 
					
						
							| 
									
										
										
										
											2016-03-08 11:43:39 +00:00
										 |  |  |     skip "HOMEBREW_GITHUB_API_TOKEN is required" unless GitHub.api_credentials | 
					
						
							| 
									
										
										
										
											2016-01-11 22:07:04 +08:00
										 |  |  |     assert_predicate @tap, :private? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   def test_install_tap_already_tapped_error | 
					
						
							| 
									
										
										
										
											2016-04-04 03:18:55 -07:00
										 |  |  |     setup_git_repo | 
					
						
							|  |  |  |     already_tapped_tap = Tap.new("Homebrew", "foo") | 
					
						
							|  |  |  |     assert_equal true, already_tapped_tap.installed? | 
					
						
							|  |  |  |     assert_raises(TapAlreadyTappedError) { already_tapped_tap.install } | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_install_tap_remote_match_already_tapped_error | 
					
						
							|  |  |  |     setup_git_repo | 
					
						
							|  |  |  |     already_tapped_tap = Tap.new("Homebrew", "foo") | 
					
						
							|  |  |  |     assert_equal true, already_tapped_tap.installed? | 
					
						
							| 
									
										
										
										
											2016-08-05 22:04:59 -07:00
										 |  |  |     right_remote = @tap.remote | 
					
						
							| 
									
										
										
										
											2016-09-17 15:32:44 +01:00
										 |  |  |     assert_raises(TapAlreadyTappedError) { already_tapped_tap.install clone_target: right_remote } | 
					
						
							| 
									
										
										
										
											2016-04-04 03:18:55 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_install_tap_remote_mismatch_error | 
					
						
							|  |  |  |     setup_git_repo | 
					
						
							|  |  |  |     already_tapped_tap = Tap.new("Homebrew", "foo") | 
					
						
							| 
									
										
										
										
											2016-04-19 15:18:54 +08:00
										 |  |  |     touch @tap.path/".git/shallow" | 
					
						
							| 
									
										
										
										
											2016-04-04 03:18:55 -07:00
										 |  |  |     assert_equal true, already_tapped_tap.installed? | 
					
						
							|  |  |  |     wrong_remote = "#{@tap.remote}-oops" | 
					
						
							| 
									
										
										
										
											2016-09-17 15:32:44 +01:00
										 |  |  |     assert_raises(TapRemoteMismatchError) { already_tapped_tap.install clone_target: wrong_remote, full_clone: true } | 
					
						
							| 
									
										
										
										
											2016-04-04 03:18:55 -07:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_install_tap_already_unshallow_error | 
					
						
							|  |  |  |     setup_git_repo | 
					
						
							|  |  |  |     already_tapped_tap = Tap.new("Homebrew", "foo") | 
					
						
							| 
									
										
										
										
											2016-09-17 15:32:44 +01:00
										 |  |  |     assert_raises(TapAlreadyUnshallowError) { already_tapped_tap.install full_clone: true } | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_uninstall_tap_unavailable_error | 
					
						
							|  |  |  |     tap = Tap.new("Homebrew", "bar") | 
					
						
							|  |  |  |     assert_raises(TapUnavailableError) { tap.uninstall } | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_install_git_error | 
					
						
							|  |  |  |     tap = Tap.new("user", "repo") | 
					
						
							|  |  |  |     assert_raises(ErrorDuringExecution) do | 
					
						
							| 
									
										
										
										
											2016-09-17 15:32:44 +01:00
										 |  |  |       shutup { tap.install clone_target: "file:///not/existed/remote/url" } | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     end | 
					
						
							|  |  |  |     refute_predicate tap, :installed? | 
					
						
							|  |  |  |     refute_predicate Tap::TAP_DIRECTORY/"user", :exist? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_install_and_uninstall | 
					
						
							|  |  |  |     setup_tap_files | 
					
						
							|  |  |  |     setup_git_repo | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     tap = Tap.new("Homebrew", "bar") | 
					
						
							| 
									
										
										
										
											2016-09-17 15:32:44 +01:00
										 |  |  |     shutup { tap.install clone_target: @tap.path/".git" } | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     assert_predicate tap, :installed? | 
					
						
							|  |  |  |     assert_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :file? | 
					
						
							|  |  |  |     shutup { tap.uninstall } | 
					
						
							|  |  |  |     refute_predicate tap, :installed? | 
					
						
							|  |  |  |     refute_predicate HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1", :exist? | 
					
						
							|  |  |  |     refute_predicate HOMEBREW_PREFIX/"share/man/man1", :exist? | 
					
						
							|  |  |  |   ensure | 
					
						
							| 
									
										
										
										
											2016-07-09 13:51:19 +01:00
										 |  |  |     (HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist? | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_pin_and_unpin | 
					
						
							|  |  |  |     refute_predicate @tap, :pinned? | 
					
						
							|  |  |  |     assert_raises(TapPinStatusError) { @tap.unpin } | 
					
						
							|  |  |  |     @tap.pin | 
					
						
							|  |  |  |     assert_predicate @tap, :pinned? | 
					
						
							|  |  |  |     assert_raises(TapPinStatusError) { @tap.pin } | 
					
						
							|  |  |  |     @tap.unpin | 
					
						
							|  |  |  |     refute_predicate @tap, :pinned? | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2016-04-12 18:51:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def test_config | 
					
						
							|  |  |  |     setup_git_repo | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert_nil @tap.config["foo"] | 
					
						
							|  |  |  |     @tap.config["foo"] = "bar" | 
					
						
							|  |  |  |     assert_equal "bar", @tap.config["foo"] | 
					
						
							|  |  |  |     @tap.config["foo"] = nil | 
					
						
							|  |  |  |     assert_nil @tap.config["foo"] | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 18:04:25 +08:00
										 |  |  | class CoreTapTest < Homebrew::TestCase | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |   include FileUtils | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   def setup | 
					
						
							| 
									
										
										
										
											2016-03-07 18:04:25 +08:00
										 |  |  |     @repo = CoreTap.new | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_attributes | 
					
						
							|  |  |  |     assert_equal "Homebrew", @repo.user | 
					
						
							| 
									
										
										
										
											2016-02-26 19:43:49 +08:00
										 |  |  |     assert_equal "core", @repo.repo | 
					
						
							|  |  |  |     assert_equal "homebrew/core", @repo.name | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |     assert_equal [], @repo.command_files | 
					
						
							|  |  |  |     assert_predicate @repo, :installed? | 
					
						
							|  |  |  |     refute_predicate @repo, :pinned? | 
					
						
							|  |  |  |     assert_predicate @repo, :official? | 
					
						
							| 
									
										
										
										
											2016-03-07 18:04:25 +08:00
										 |  |  |     assert_predicate @repo, :core_tap? | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_forbidden_operations | 
					
						
							|  |  |  |     assert_raises(RuntimeError) { @repo.uninstall } | 
					
						
							|  |  |  |     assert_raises(RuntimeError) { @repo.pin } | 
					
						
							|  |  |  |     assert_raises(RuntimeError) { @repo.unpin } | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_files | 
					
						
							|  |  |  |     @formula_file = @repo.formula_dir/"foo.rb" | 
					
						
							|  |  |  |     @formula_file.write <<-EOS.undent
 | 
					
						
							|  |  |  |       class Foo < Formula | 
					
						
							|  |  |  |         url "https://example.com/foo-1.0.tar.gz" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     EOS | 
					
						
							|  |  |  |     @alias_file = @repo.alias_dir/"bar" | 
					
						
							|  |  |  |     @alias_file.parent.mkpath | 
					
						
							| 
									
										
										
										
											2016-03-05 20:03:43 +08:00
										 |  |  |     ln_s @formula_file, @alias_file | 
					
						
							| 
									
										
										
										
											2015-12-19 21:12:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     assert_equal [@formula_file], @repo.formula_files | 
					
						
							|  |  |  |     assert_equal ["foo"], @repo.formula_names | 
					
						
							|  |  |  |     assert_equal [@alias_file], @repo.alias_files | 
					
						
							|  |  |  |     assert_equal ["bar"], @repo.aliases | 
					
						
							|  |  |  |     assert_equal @repo.alias_table, "bar" => "foo" | 
					
						
							|  |  |  |     assert_equal @repo.alias_reverse_table, "foo" => ["bar"] | 
					
						
							|  |  |  |   ensure | 
					
						
							|  |  |  |     @formula_file.unlink | 
					
						
							|  |  |  |     @repo.alias_dir.rmtree | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |