aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-11-01 21:45:50 -0700
committerelijah <elijah@riseup.net>2012-11-01 21:45:50 -0700
commit134c09ef9e58dc52136610e480b13176a16d9715 (patch)
tree2c2999bc111b75efd4fde5c61adecc2aa6bcc689 /test
parentf0e8ae8b25e4fdbb0420756e1dada3d329d6a13d (diff)
downloadleap_cli-134c09ef9e58dc52136610e480b13176a16d9715.tar.gz
leap_cli-134c09ef9e58dc52136610e480b13176a16d9715.tar.bz2
added some initial tests. yeah.
Diffstat (limited to 'test')
-rw-r--r--test/test_helper.rb20
-rw-r--r--test/unit/config_object_list_test.rb20
-rw-r--r--test/unit/config_object_test.rb10
-rw-r--r--test/unit/test_helper.rb1
4 files changed, 46 insertions, 5 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 2e33705..e761086 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,9 +1,19 @@
-require 'test/unit'
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
+require 'rubygems'
+require 'minitest/autorun'
+require 'leap_cli'
-# Add test libraries you want to use here, e.g. mocha
-
-class Test::Unit::TestCase
+class MiniTest::Unit::TestCase
# Add global extensions to the test case class here
-
+
+ def manager
+ @manager ||= begin
+ LeapCli::Path.set_root(File.dirname(__FILE__))
+ manager = LeapCli::Config::Manager.new
+ manager.load
+ manager
+ end
+ end
+
end
diff --git a/test/unit/config_object_list_test.rb b/test/unit/config_object_list_test.rb
new file mode 100644
index 0000000..a0ca9d5
--- /dev/null
+++ b/test/unit/config_object_list_test.rb
@@ -0,0 +1,20 @@
+require File.dirname(__FILE__) + '/test_helper'
+
+class TestMeme < MiniTest::Unit::TestCase
+
+ def test_node_search
+ nodes = manager.nodes['name' => 'vpn1']
+ assert_equal 1, nodes.size
+ assert_equal 'vpn1', nodes.values.first.name
+ end
+
+ def test_complex_node_search
+ nodes = manager.nodes['dns.public' => true]
+ expected = [{"domain_full"=>"ns1.rewire.co"}, {"domain_full"=>"ns2.rewire.co"}, {"domain_full"=>"vpn1.rewire.co"}, {"domain_full"=>"web1.rewire.co"}]
+ assert_equal expected.size, nodes.size
+ assert_equal expected, nodes.fields('domain.full')
+ end
+
+
+
+end
diff --git a/test/unit/config_object_test.rb b/test/unit/config_object_test.rb
new file mode 100644
index 0000000..2cd6dff
--- /dev/null
+++ b/test/unit/config_object_test.rb
@@ -0,0 +1,10 @@
+require File.expand_path('test_helper', File.dirname(__FILE__))
+
+class TestMeme < MiniTest::Unit::TestCase
+
+ def test_bracket_lookup
+ vpn1 = manager.nodes['vpn1']
+ assert_equal 'vpn1.rewire.co', vpn1['domain.full']
+ end
+
+end
diff --git a/test/unit/test_helper.rb b/test/unit/test_helper.rb
new file mode 100644
index 0000000..ade21a0
--- /dev/null
+++ b/test/unit/test_helper.rb
@@ -0,0 +1 @@
+require File.dirname(File.dirname(__FILE__)) + '/test_helper' \ No newline at end of file