aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/test_updater.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2010-01-29 10:41:03 -0800
committerAdam Vandenberg2010-02-02 09:08:10 -0800
commita309403d8ab3830fc0a02a861c7ccdefedfe4da1 (patch)
tree09a22293e7b810f1e27bd8e3dd59bcca97f18c12 /Library/Homebrew/test/test_updater.rb
parent5474cf1a95616243f5592c8c5951048ea5cbafe3 (diff)
downloadbrew-a309403d8ab3830fc0a02a861c7ccdefedfe4da1.tar.bz2
Update test suite.
* Break single test case class into several test cases. * Fix broken arch test. * Make update tests optional (seem to only work for mxcl). * Add more tests. * Move fixtures to separate folder.
Diffstat (limited to 'Library/Homebrew/test/test_updater.rb')
-rw-r--r--Library/Homebrew/test/test_updater.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb
new file mode 100644
index 000000000..893589983
--- /dev/null
+++ b/Library/Homebrew/test/test_updater.rb
@@ -0,0 +1,67 @@
+class UpdaterTests < Test::Unit::TestCase
+ OUTSIDE_PREFIX = '/tmp'
+ def outside_prefix
+ Dir.chdir(OUTSIDE_PREFIX) { yield }
+ end
+
+ def fixture(name)
+ self.class.fixture_data[name]
+ end
+
+ def self.fixture_data
+ unless @fixture_data
+ require 'yaml'
+ @fixture_data = YAML.load_file(Pathname.new(ABS__FILE__).parent.realpath + 'fixtures/updater_fixture.yaml')
+ end
+ @fixture_data
+ end
+
+ def test_update_homebrew_without_any_changes
+ outside_prefix do
+ updater = RefreshBrewMock.new
+ updater.in_prefix_expect("git checkout master")
+ updater.in_prefix_expect("git pull origin master", "Already up-to-date.\n")
+
+ assert_equal false, updater.update_from_masterbrew!
+ assert updater.expectations_met?
+ assert updater.updated_formulae.empty?
+ assert updater.added_formulae.empty?
+ end
+ end
+
+ def test_update_homebrew_without_formulae_changes
+ outside_prefix do
+ updater = RefreshBrewMock.new
+ updater.in_prefix_expect("git checkout master")
+ output = fixture('update_git_pull_output_without_formulae_changes')
+ updater.in_prefix_expect("git pull origin master", output)
+
+ assert_equal true, updater.update_from_masterbrew!
+ assert !updater.pending_formulae_changes?
+ assert updater.updated_formulae.empty?
+ assert updater.added_formulae.empty?
+ end
+ end
+
+ def test_update_homebrew_with_formulae_changes
+ outside_prefix do
+ updater = RefreshBrewMock.new
+ updater.in_prefix_expect("git checkout master")
+ output = fixture('update_git_pull_output_with_formulae_changes')
+ updater.in_prefix_expect("git pull origin master", output)
+
+ assert_equal true, updater.update_from_masterbrew!
+ assert updater.pending_formulae_changes?
+ assert_equal %w{ xar yajl }, updater.updated_formulae
+ assert_equal %w{ antiword bash-completion ddrescue dict lua }, updater.added_formulae
+ end
+ end
+
+ def test_updater_returns_current_revision
+ outside_prefix do
+ updater = RefreshBrewMock.new
+ updater.in_prefix_expect('git log -l -1 --pretty=format:%H', 'the-revision-hash')
+ assert_equal 'the-revision-hash', updater.current_revision
+ end
+ end
+end