aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/test_formula_pin.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test/test_formula_pin.rb')
-rw-r--r--Library/Homebrew/test/test_formula_pin.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_formula_pin.rb b/Library/Homebrew/test/test_formula_pin.rb
new file mode 100644
index 000000000..938fd51f8
--- /dev/null
+++ b/Library/Homebrew/test/test_formula_pin.rb
@@ -0,0 +1,48 @@
+require 'testing_env'
+require 'formula_pin'
+
+class FormulaPinTests < Test::Unit::TestCase
+ class FormulaDouble
+ def name
+ "double"
+ end
+
+ def rack
+ Pathname.new("#{HOMEBREW_CELLAR}/#{name}")
+ end
+ end
+
+ def setup
+ @f = FormulaDouble.new
+ @pin = FormulaPin.new(@f)
+ @f.rack.mkpath
+ end
+
+ def test_not_pinnable
+ assert !@pin.pinnable?
+ end
+
+ def test_pinnable_if_kegs_exist
+ (@f.rack+'0.1').mkpath
+ assert @pin.pinnable?
+ end
+
+ def test_pin
+ (@f.rack+'0.1').mkpath
+ @pin.pin
+ assert @pin.pinned?
+ assert_equal 1, FormulaPin::PINDIR.children.length
+ end
+
+ def test_unpin
+ (@f.rack+'0.1').mkpath
+ @pin.pin
+ @pin.unpin
+ assert !@pin.pinned?
+ assert_equal 0, FormulaPin::PINDIR.children.length
+ end
+
+ def teardown
+ @f.rack.rmtree
+ end
+end