aboutsummaryrefslogtreecommitdiff
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
parentf0e8ae8b25e4fdbb0420756e1dada3d329d6a13d (diff)
downloadleap_cli-134c09ef9e58dc52136610e480b13176a16d9715.tar.gz
leap_cli-134c09ef9e58dc52136610e480b13176a16d9715.tar.bz2
added some initial tests. yeah.
-rw-r--r--Rakefile6
-rw-r--r--leap_cli.gemspec1
-rw-r--r--lib/leap_cli/version.rb2
-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
7 files changed, 53 insertions, 7 deletions
diff --git a/Rakefile b/Rakefile
index 51c980e..3ba9103 100644
--- a/Rakefile
+++ b/Rakefile
@@ -2,6 +2,7 @@ require "rubygems"
require "highline/import"
require "pty"
require "fileutils"
+require 'rake/testtask'
##
## HELPER
@@ -62,7 +63,10 @@ end
## TESTING
##
-# task :default => [:test,:features]
+Rake::TestTask.new do |t|
+ t.pattern = "test/unit/*_test.rb"
+end
+task :default => :test
##
## DOCUMENTATION
diff --git a/leap_cli.gemspec b/leap_cli.gemspec
index 20e50a8..f51636a 100644
--- a/leap_cli.gemspec
+++ b/leap_cli.gemspec
@@ -40,6 +40,7 @@ spec = Gem::Specification.new do |s|
## DEPENDENCIES
##
s.add_development_dependency('rake')
+ s.add_development_dependency('minitest')
#s.add_development_dependency('rdoc')
#s.add_development_dependency('aruba')
diff --git a/lib/leap_cli/version.rb b/lib/leap_cli/version.rb
index 437d861..0f69f04 100644
--- a/lib/leap_cli/version.rb
+++ b/lib/leap_cli/version.rb
@@ -1,6 +1,6 @@
module LeapCli
unless defined?(LeapCli::VERSION)
- VERSION = '0.1.0'
+ VERSION = '0.1.1'
SUMMARY = 'Command line interface to the LEAP platform'
DESCRIPTION = 'The command "leap" can be used to manage a bevy of servers running the LEAP platform from the comfort of your own home.'
end
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