Permalink
Browse files

Tests passing using fast_ey almost everywhere (much faster)

  • Loading branch information...
1 parent bb3dbdb commit b9f9f1638334213ac8be0c6d3d58e743559efaa1 @martinemde martinemde committed with martinemde Feb 10, 2012
View
@@ -1,17 +1,9 @@
#!/usr/bin/env ruby
$:.unshift(File.expand_path('../../lib', __FILE__))
require 'engineyard/cli'
-require 'engineyard/error'
-require 'engineyard-cloud-client/errors'
begin
EY::CLI.start
-rescue EY::Error, EY::CloudClient::Error => e
- EY.ui.print_exception(e)
- exit(1)
-rescue Interrupt => e
- puts
- EY.ui.print_exception(e)
- EY.ui.say("Quitting...")
+rescue
exit(1)
end
View
@@ -9,13 +9,23 @@ class CLI < EY::Thor
require 'engineyard/cli/web'
require 'engineyard/cli/api'
require 'engineyard/cli/ui'
+ require 'engineyard/error'
+ require 'engineyard-cloud-client/errors'
include Thor::Actions
def self.start(*)
Thor::Base.shell = EY::CLI::UI
EY.ui = EY::CLI::UI.new
super
+ rescue EY::Error, EY::CloudClient::Error => e
+ EY.ui.print_exception(e)
+ raise
+ rescue Interrupt => e
+ puts
+ EY.ui.print_exception(e)
+ EY.ui.say("Quitting...")
+ raise
end
desc "deploy [--environment ENVIRONMENT] [--ref GIT-REF]",
@@ -17,7 +17,7 @@ def verify_ran(scenario)
include_examples "it takes an environment name and an account name"
it "fails when given a bad option" do
- ey %w[web enable --lots --of --bogus --options], :expect_failure => true
+ fast_failing_ey %w[web enable --lots --of --bogus --options]
@err.should include("Unknown switches")
end
end
@@ -58,7 +58,7 @@ def command_to_run(opts)
it "errors with file not found" do
api_scenario "one app, one environment"
- ey(%w[recipes upload --environment giblets -f recipes.tgz], :expect_failure => true)
+ fast_failing_ey(%w[recipes upload --environment giblets -f recipes.tgz])
@err.should match(/Recipes file not found: recipes.tgz/i)
end
end
View
@@ -31,7 +31,7 @@ def command_to_run(opts)
it "runs the command on the right servers" do
api_scenario "one app, one environment"
- run_ey(:ssh_command => "ls", :environment => 'giblets', :verbose => true)
+ ey command_to_run(:ssh_command => "ls", :environment => 'giblets', :verbose => true)
@hosts.each do |host|
@raw_ssh_commands.select do |command|
command =~ /^ssh turkey@#{host}.+ ls$/
@@ -44,13 +44,13 @@ def command_to_run(opts)
it "raises an error when there are no matching hosts" do
api_scenario "one app, one environment, no instances"
- run_ey({:ssh_command => "ls", :environment => 'giblets', :verbose => true}, :expect_failure => true)
+ ey command_to_run({:ssh_command => "ls", :environment => 'giblets', :verbose => true}), :expect_failure => true
end
it "responds correctly when there is no command" do
if @hosts.count != 1
api_scenario "one app, one environment"
- run_ey({:environment => 'giblets', :verbose => true}, :expect_failure => true)
+ ey command_to_run({:environment => 'giblets', :verbose => true}), :expect_failure => true
end
end
end
@@ -128,7 +128,7 @@ def command_to_run(opts)
it "fails just like the ssh command fails" do
api_scenario "one app, one environment"
- run_ey({:ssh_command => "ls", :environment => 'giblets', :verbose => true}, :expect_failure => true)
+ ey command_to_run({:ssh_command => "ls", :environment => 'giblets', :verbose => true}), :expect_failure => true
end
end
@@ -26,9 +26,14 @@ module IntegrationHelpers
def run_ey(command_options, ey_options={})
if respond_to?(:extra_ey_options) # needed for ssh tests
ey_options.merge!(extra_ey_options)
+ return ey(command_to_run(command_options), ey_options)
end
- ey(command_to_run(command_options), ey_options)
+ if ey_options[:expect_failure]
+ fast_failing_ey(command_to_run(command_options))
+ else
+ fast_ey(command_to_run(command_options))
+ end
end
def make_scenario(opts)
@@ -123,7 +128,12 @@ def capture_stdout_into(stream)
end
def ey(args = [], options = {}, &block)
+ if respond_to?(:extra_ey_options) # needed for ssh tests
+ options.merge!(extra_ey_options)
+ end
+
hide_err = options.has_key?(:hide_err) ? options[:hide_err] : options[:expect_failure]
+
path_prepends = options[:prepend_to_path]
ey_env = {
@@ -86,9 +86,8 @@
end
it "returns the error message to the user" do
- lambda do
- fast_ey(command_to_run({:environment => "giblets", :account => "main"}))
- end.should raise_error(EY::CloudClient::Error, /400.*Important infos/)
+ fast_failing_ey(command_to_run({:environment => "giblets", :account => "main"}))
+ @err.should match(/400.*Important infos/)
end
end
@@ -98,7 +97,7 @@
shared_examples_for "it takes an environment name" do
it "operates on the current environment by default" do
api_scenario "one app, one environment"
- run_ey({:environment => nil}, {:debug => true})
+ run_ey(:environment => nil)
verify_ran(make_scenario({
:environment => 'giblets',
:application => 'rails232app',
@@ -109,7 +108,8 @@
it "complains when you specify a nonexistent environment" do
api_scenario "one app, one environment"
- run_ey({:environment => 'typo-happens-here'}, {:expect_failure => true})
+ # This test must shell out (not sure why, plz FIXME)
+ ey command_to_run(:environment => 'typo-happens-here'), {:expect_failure => true}
@err.should match(/No environment found matching .*typo-happens-here/i)
end

0 comments on commit b9f9f16

Please sign in to comment.