aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
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