Clean up updater tests
This commit is contained in:
parent
87850d00cd
commit
908d7bdecf
@ -39,7 +39,7 @@ class UpdaterTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fixture(name)
|
def fixture(name)
|
||||||
self.class.fixture_data[name]
|
self.class.fixture_data[name] || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.fixture_data
|
def self.fixture_data
|
||||||
@ -51,49 +51,43 @@ class UpdaterTests < Homebrew::TestCase
|
|||||||
@report = Report.new
|
@report = Report.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_update(diff_output="")
|
def perform_update(fixture_name="")
|
||||||
HOMEBREW_REPOSITORY.cd do
|
@updater.diff = fixture(fixture_name)
|
||||||
@updater.diff = diff_output
|
@updater.in_repo_expect("git checkout -q master")
|
||||||
@updater.in_repo_expect("git checkout -q master")
|
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "1234abcd")
|
||||||
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "1234abcd")
|
@updater.in_repo_expect("git config core.autocrlf false")
|
||||||
@updater.in_repo_expect("git config core.autocrlf false")
|
@updater.in_repo_expect("git pull -q origin refs/heads/master:refs/remotes/origin/master")
|
||||||
@updater.in_repo_expect("git pull -q origin refs/heads/master:refs/remotes/origin/master")
|
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef")
|
||||||
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef")
|
@updater.pull!
|
||||||
@updater.pull!
|
@report.update(@updater.report)
|
||||||
@report.update(@updater.report)
|
assert_predicate @updater, :expectations_met?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_homebrew_without_any_changes
|
def test_update_homebrew_without_any_changes
|
||||||
perform_update
|
perform_update
|
||||||
assert_predicate @updater, :expectations_met?
|
|
||||||
assert_empty @report
|
assert_empty @report
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_homebrew_without_formulae_changes
|
def test_update_homebrew_without_formulae_changes
|
||||||
perform_update(fixture('update_git_diff_output_without_formulae_changes'))
|
perform_update("update_git_diff_output_without_formulae_changes")
|
||||||
assert_predicate @updater, :expectations_met?
|
|
||||||
assert_empty @report.select_formula(:M)
|
assert_empty @report.select_formula(:M)
|
||||||
assert_empty @report.select_formula(:A)
|
assert_empty @report.select_formula(:A)
|
||||||
assert_empty @report.select_formula(:D)
|
assert_empty @report.select_formula(:D)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_homebrew_with_formulae_changes
|
def test_update_homebrew_with_formulae_changes
|
||||||
perform_update(fixture('update_git_diff_output_with_formulae_changes'))
|
perform_update("update_git_diff_output_with_formulae_changes")
|
||||||
assert_predicate @updater, :expectations_met?
|
|
||||||
assert_equal %w{ xar yajl }, @report.select_formula(:M)
|
assert_equal %w{ xar yajl }, @report.select_formula(:M)
|
||||||
assert_equal %w{ antiword bash-completion ddrescue dict lua }, @report.select_formula(:A)
|
assert_equal %w{ antiword bash-completion ddrescue dict lua }, @report.select_formula(:A)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_homebrew_with_removed_formulae
|
def test_update_homebrew_with_removed_formulae
|
||||||
perform_update(fixture('update_git_diff_output_with_removed_formulae'))
|
perform_update("update_git_diff_output_with_removed_formulae")
|
||||||
assert_predicate @updater, :expectations_met?
|
|
||||||
assert_equal %w{libgsasl}, @report.select_formula(:D)
|
assert_equal %w{libgsasl}, @report.select_formula(:D)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_homebrew_with_changed_filetype
|
def test_update_homebrew_with_changed_filetype
|
||||||
perform_update(fixture('update_git_diff_output_with_changed_filetype'))
|
perform_update("update_git_diff_output_with_changed_filetype")
|
||||||
assert_predicate @updater, :expectations_met?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_homebrew_with_restructured_tap
|
def test_update_homebrew_with_restructured_tap
|
||||||
@ -101,9 +95,8 @@ class UpdaterTests < Homebrew::TestCase
|
|||||||
@updater = UpdaterMock.new(repo)
|
@updater = UpdaterMock.new(repo)
|
||||||
repo.join("Formula").mkpath
|
repo.join("Formula").mkpath
|
||||||
|
|
||||||
perform_update(fixture('update_git_diff_output_with_restructured_tap'))
|
perform_update("update_git_diff_output_with_restructured_tap")
|
||||||
|
|
||||||
assert_predicate @updater, :expectations_met?
|
|
||||||
assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:A)
|
assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:A)
|
||||||
assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:D)
|
assert_equal %w{foo/bar/git foo/bar/lua}, @report.select_formula(:D)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user