From: Martyn Taylor <mtaylor(a)redhat.com>
---
spec/base_command_spec.rb | 83 ------------------------------
spec/build_command_spec.rb | 77 ----------------------------
spec/command/base_command_spec.rb | 83 ++++++++++++++++++++++++++++++
spec/command/build_command_spec.rb | 77 ++++++++++++++++++++++++++++
spec/command/config_parser_spec.rb | 96 +++++++++++++++++++++++++++++++++++
spec/command/import_command_spec.rb | 57 +++++++++++++++++++++
spec/command/list_command_spec.rb | 22 ++++++++
spec/command/push_command_spec.rb | 70 +++++++++++++++++++++++++
spec/config_parser_spec.rb | 96 -----------------------------------
spec/import_command_spec.rb | 57 ---------------------
spec/list_command_spec.rb | 22 --------
spec/push_command_spec.rb | 70 -------------------------
spec/spec_helper.rb | 10 ++++
spec/vcr_setup.rb | 24 +++++++++
14 files changed, 439 insertions(+), 405 deletions(-)
delete mode 100644 spec/base_command_spec.rb
delete mode 100644 spec/build_command_spec.rb
create mode 100644 spec/command/base_command_spec.rb
create mode 100644 spec/command/build_command_spec.rb
create mode 100644 spec/command/config_parser_spec.rb
create mode 100644 spec/command/import_command_spec.rb
create mode 100644 spec/command/list_command_spec.rb
create mode 100644 spec/command/push_command_spec.rb
delete mode 100644 spec/config_parser_spec.rb
delete mode 100644 spec/import_command_spec.rb
delete mode 100644 spec/list_command_spec.rb
delete mode 100644 spec/push_command_spec.rb
create mode 100644 spec/vcr_setup.rb
diff --git a/spec/base_command_spec.rb b/spec/base_command_spec.rb
deleted file mode 100644
index 63188e6..0000000
--- a/spec/base_command_spec.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'spec_helper'
-
-module Aeolus
- module CLI
- describe BaseCommand do
- describe "configure_active_resource" do
- it "should setup ActiveResource with endpoint and authentication" do
- basec = BaseCommand.new
- Aeolus::CLI::Base.site.to_s.should ==
"http://localhost/conductor/api"
- Aeolus::CLI::Base.user.to_s.should == "admin"
- Aeolus::CLI::Base.password.to_s.should == "password"
- end
- end
-
- describe "#read_file" do
-
- it "should return nil when it cannot find file" do
- b = BaseCommand.new
- b.send(:read_file, "foo.fake").should be_nil
- end
-
- it "should read file content into string variable" do
- b = BaseCommand.new
- template_str = b.send(:read_file, "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl")
- template_str.should include("<template>")
- end
- end
-
- describe "#is_file?" do
- it "should return false if no file found" do
- b = BaseCommand.new
- b.send(:is_file?, "foo.fake").should be_false
- end
- it "should return true if file found" do
- b = BaseCommand.new
- valid_file = "#{File.dirname(__FILE__)}" +
"/../examples/aeolus-cli"
- b.instance_eval {@config_location = valid_file}
- b.send(:is_file?, valid_file).should be_true
- end
- end
-
- describe "#write_file" do
- it "should write a new file" do
- b = BaseCommand.new
- new_file = "/tmp/foo.fake"
- b.instance_eval {@config_location = new_file}
- b.send(:write_file)
- conf = YAML::load(File.open(File.expand_path(new_file)))
- conf.has_key?(:conductor).should be_true
- File.delete(new_file)
- end
- end
-
- describe "#validate_xml_document?" do
- it "should return errors given non compliant xml" do
- b = BaseCommand.new
- errors = b.send(:validate_xml_document, "examples/tdl.rng",
File.read("spec/fixtures/invalid_template.tdl"))
- errors.length.should > 0
- end
-
- it "should return no errors" do
- b = BaseCommand.new
- errors = b.send(:validate_xml_document, "examples/tdl.rng",
File.read("spec/fixtures/valid_template.tdl"))
- errors.length.should == 0
- end
- end
- end
- end
-end
diff --git a/spec/build_command_spec.rb b/spec/build_command_spec.rb
deleted file mode 100644
index c9887d0..0000000
--- a/spec/build_command_spec.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'spec_helper'
-
-module Aeolus
- module CLI
- describe BuildCommand do
- before(:each) do
- @options[:target] = ['mock','ec2']
- @options[:template] = "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl"
- end
-
- describe "#run" do
- it "should kick off a build with valid options" do
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- end
- it "should exit with a message if only image id is provided" do
- @options.delete(:template)
- @options.delete(:target)
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not
currently supported")
- end
- it "should exit with appropriate message when a non compliant template is
given" do
- @options[:template] = "spec/fixtures/invalid_template.tdl"
- @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
- b = BuildCommand.new(@options, @output)
- begin
- b.run
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("ERROR: The given Template does not conform
to the TDL Schema")
- end
- end
-
- describe "#combo_implemented?" do
- it "should give useful feedback if no template or target is specified"
do
- @options[:template] = ''
- @options[:target] = []
- b = BuildCommand.new(@options, @output)
- begin
- b.combo_implemented?
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not
currently supported")
- end
- end
- end
- end
-end
diff --git a/spec/command/base_command_spec.rb b/spec/command/base_command_spec.rb
new file mode 100644
index 0000000..63188e6
--- /dev/null
+++ b/spec/command/base_command_spec.rb
@@ -0,0 +1,83 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+
+module Aeolus
+ module CLI
+ describe BaseCommand do
+ describe "configure_active_resource" do
+ it "should setup ActiveResource with endpoint and authentication" do
+ basec = BaseCommand.new
+ Aeolus::CLI::Base.site.to_s.should ==
"http://localhost/conductor/api"
+ Aeolus::CLI::Base.user.to_s.should == "admin"
+ Aeolus::CLI::Base.password.to_s.should == "password"
+ end
+ end
+
+ describe "#read_file" do
+
+ it "should return nil when it cannot find file" do
+ b = BaseCommand.new
+ b.send(:read_file, "foo.fake").should be_nil
+ end
+
+ it "should read file content into string variable" do
+ b = BaseCommand.new
+ template_str = b.send(:read_file, "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl")
+ template_str.should include("<template>")
+ end
+ end
+
+ describe "#is_file?" do
+ it "should return false if no file found" do
+ b = BaseCommand.new
+ b.send(:is_file?, "foo.fake").should be_false
+ end
+ it "should return true if file found" do
+ b = BaseCommand.new
+ valid_file = "#{File.dirname(__FILE__)}" +
"/../examples/aeolus-cli"
+ b.instance_eval {@config_location = valid_file}
+ b.send(:is_file?, valid_file).should be_true
+ end
+ end
+
+ describe "#write_file" do
+ it "should write a new file" do
+ b = BaseCommand.new
+ new_file = "/tmp/foo.fake"
+ b.instance_eval {@config_location = new_file}
+ b.send(:write_file)
+ conf = YAML::load(File.open(File.expand_path(new_file)))
+ conf.has_key?(:conductor).should be_true
+ File.delete(new_file)
+ end
+ end
+
+ describe "#validate_xml_document?" do
+ it "should return errors given non compliant xml" do
+ b = BaseCommand.new
+ errors = b.send(:validate_xml_document, "examples/tdl.rng",
File.read("spec/fixtures/invalid_template.tdl"))
+ errors.length.should > 0
+ end
+
+ it "should return no errors" do
+ b = BaseCommand.new
+ errors = b.send(:validate_xml_document, "examples/tdl.rng",
File.read("spec/fixtures/valid_template.tdl"))
+ errors.length.should == 0
+ end
+ end
+ end
+ end
+end
diff --git a/spec/command/build_command_spec.rb b/spec/command/build_command_spec.rb
new file mode 100644
index 0000000..c9887d0
--- /dev/null
+++ b/spec/command/build_command_spec.rb
@@ -0,0 +1,77 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+
+module Aeolus
+ module CLI
+ describe BuildCommand do
+ before(:each) do
+ @options[:target] = ['mock','ec2']
+ @options[:template] = "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl"
+ end
+
+ describe "#run" do
+ it "should kick off a build with valid options" do
+ b = BuildCommand.new(@options, @output)
+ begin
+ b.run
+ rescue SystemExit => e
+ e.status.should == 0
+ end
+ $stdout.string.should include("Image:")
+ $stdout.string.should include("Target Image:")
+ $stdout.string.should include("Build:")
+ end
+ it "should exit with a message if only image id is provided" do
+ @options.delete(:template)
+ @options.delete(:target)
+ @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
+ b = BuildCommand.new(@options, @output)
+ begin
+ b.run
+ rescue SystemExit => e
+ e.status.should == 1
+ end
+ $stdout.string.should include("This combination of parameters is not
currently supported")
+ end
+ it "should exit with appropriate message when a non compliant template is
given" do
+ @options[:template] = "spec/fixtures/invalid_template.tdl"
+ @options[:image] = '825c94d1-1353-48ca-87b9-36f02e069a8d'
+ b = BuildCommand.new(@options, @output)
+ begin
+ b.run
+ rescue SystemExit => e
+ e.status.should == 1
+ end
+ $stdout.string.should include("ERROR: The given Template does not conform
to the TDL Schema")
+ end
+ end
+
+ describe "#combo_implemented?" do
+ it "should give useful feedback if no template or target is specified"
do
+ @options[:template] = ''
+ @options[:target] = []
+ b = BuildCommand.new(@options, @output)
+ begin
+ b.combo_implemented?
+ rescue SystemExit => e
+ e.status.should == 1
+ end
+ $stdout.string.should include("This combination of parameters is not
currently supported")
+ end
+ end
+ end
+ end
+end
diff --git a/spec/command/config_parser_spec.rb b/spec/command/config_parser_spec.rb
new file mode 100644
index 0000000..8cb3c7c
--- /dev/null
+++ b/spec/command/config_parser_spec.rb
@@ -0,0 +1,96 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+
+module Aeolus
+ module CLI
+ describe ConfigParser do
+ it "should parse the specified command" do
+ config_parser = ConfigParser.new(%w(list --images))
+ config_parser.process
+ config_parser.command.should == 'list'
+ end
+
+ it "should exit gracefully when a required subcommand is not provided"
do
+ begin
+ silence_stream(STDOUT) do
+ config_parser = ConfigParser.new(%w(list))
+ config_parser.process
+ config_parser.should_receive(:exit).with(1)
+ end
+ rescue SystemExit => e
+ e.status.should == 1
+ end
+ end
+
+ it "should notify the user of an invalid command" do
+ config_parser = ConfigParser.new(%w(sparkle))
+ config_parser.should_receive(:exit).with(0)
+ silence_stream(STDOUT) do
+ config_parser.process
+ end
+ end
+
+ it "should exit gracefully with bad params" do
+ begin
+ silence_stream(STDOUT) do
+ ConfigParser.new(%w(delete --fred)).should_receive(:exit).with(1)
+ end
+ rescue SystemExit => e
+ e.status.should == 1
+ end
+ end
+
+ it "should set options hash for valid general options" do
+ config_parser = ConfigParser.new(%w(list --user joe --password cloud --images))
+ config_parser.options[:user].should == 'joe'
+ config_parser.options[:password].should == 'cloud'
+ config_parser.options[:subcommand].should == :images
+ end
+
+ it "should set options hash for valid list options" do
+ config_parser = ConfigParser.new(%w(list --builds 12345))
+ config_parser.options[:subcommand].should == :builds
+ config_parser.options[:id].should == '12345'
+ end
+
+ it "should set options hash for valid build options" do
+ config_parser = ConfigParser.new(%w(build --target ec2,rackspace --image 12345
--template my.tmpl))
+ config_parser.options[:target].should == ['ec2','rackspace']
+ config_parser.options[:image].should == '12345'
+ config_parser.options[:template].should == 'my.tmpl'
+ end
+
+ it "should set options hash for valid push options" do
+ config_parser = ConfigParser.new(%w(push --provider ec2-us-east1 --id 12345))
+ config_parser.options[:provider].should == ['ec2-us-east1']
+ config_parser.options[:id].should == '12345'
+ end
+
+ it "should set options hash for valid delete options" do
+ config_parser = ConfigParser.new(%w(delete --build 12345))
+ config_parser.options[:build].should == '12345'
+ end
+
+ it "should set options hash for valid import options" do
+ config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a
--description /path/to/file --id ami-123456 --target ec2))
+ config_parser.options[:provider].should == ['ec2-us-east-1a']
+ config_parser.options[:target].should == ['ec2']
+ config_parser.options[:description].should == '/path/to/file'
+ config_parser.options[:id].should == 'ami-123456'
+ end
+ end
+ end
+end
diff --git a/spec/command/import_command_spec.rb b/spec/command/import_command_spec.rb
new file mode 100644
index 0000000..9477f9e
--- /dev/null
+++ b/spec/command/import_command_spec.rb
@@ -0,0 +1,57 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+
+module Aeolus
+ module CLI
+ describe ImportCommand do
+ before(:each) do
+ @options[:id] = "ami-test"
+ @options[:target] = "ec2"
+ @options[:provider] = "ec2-us-east-1"
+ end
+
+ describe "#import_image" do
+ it "should import an image with default description values" do
+ importc = ImportCommand.new(@options)
+ begin
+ importc.import_image
+ rescue SystemExit => e
+ e.status.should == 0
+ end
+ $stdout.string.should include("Image:")
+ $stdout.string.should include("Target Image:")
+ $stdout.string.should include("Build:")
+ $stdout.string.should include("Provider Image:")
+ end
+
+ it "should import an image with file description" do
+ @options[:description] = 'spec/sample_data/image_description.xml'
+ importc = ImportCommand.new(@options)
+ begin
+ importc.import_image
+ rescue SystemExit => e
+ e.status.should == 0
+ end
+ $stdout.string.should include("Image:")
+ $stdout.string.should include("Target Image:")
+ $stdout.string.should include("Build:")
+ $stdout.string.should include("Provider Image:")
+ #TODO: Add test to check that file was uploaded properly (when we have
implemented a show/view image command)
+ end
+ end
+ end
+ end
+end
diff --git a/spec/command/list_command_spec.rb b/spec/command/list_command_spec.rb
new file mode 100644
index 0000000..9a7bbbb
--- /dev/null
+++ b/spec/command/list_command_spec.rb
@@ -0,0 +1,22 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+
+module Aeolus
+ module CLI
+ describe ListCommand do
+ end
+ end
+end
diff --git a/spec/command/push_command_spec.rb b/spec/command/push_command_spec.rb
new file mode 100644
index 0000000..5694e76
--- /dev/null
+++ b/spec/command/push_command_spec.rb
@@ -0,0 +1,70 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#
http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+
+module Aeolus
+ module CLI
+ describe PushCommand do
+
+ before(:each) do
+ @options[:provider] = ['mock']
+ @options[:user] = 'admin'
+ @options[:password] = 'password'
+ end
+
+ describe "#run" do
+ before(:each) do
+ options = {}
+ options[:target] = ['mock','ec2']
+ options[:template] = "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl"
+ b = BuildCommand.new(options)
+ sleep(5)
+ tmpl_str = b.send(:read_file, options[:template])
+ b.console.build(tmpl_str, ['mock','ec2']).each do |adaptor|
+ @build_id = adaptor.image
+ end
+ b.console.shutdown
+ @options[:id] = @build_id
+ end
+
+ it "should push an image with valid options" do
+ p = PushCommand.new(@options, @output)
+ begin
+ p.run
+ rescue SystemExit => e
+ e.status.should == 0
+ end
+ $stdout.string.should include("Image:")
+ $stdout.string.should include("Provider Image:")
+ $stdout.string.should include("Build:")
+ end
+ end
+
+ describe "#combo_implemented?" do
+ it "should give useful feedback if no template or target is specified"
do
+ @options.delete(:id)
+ @options.delete(:provider)
+ b = PushCommand.new(@options, @output)
+ begin
+ b.combo_implemented?
+ rescue SystemExit => e
+ e.status.should == 1
+ end
+ $stdout.string.should include("This combination of parameters is not
currently supported")
+ end
+ end
+ end
+ end
+end
diff --git a/spec/config_parser_spec.rb b/spec/config_parser_spec.rb
deleted file mode 100644
index 8cb3c7c..0000000
--- a/spec/config_parser_spec.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'spec_helper'
-
-module Aeolus
- module CLI
- describe ConfigParser do
- it "should parse the specified command" do
- config_parser = ConfigParser.new(%w(list --images))
- config_parser.process
- config_parser.command.should == 'list'
- end
-
- it "should exit gracefully when a required subcommand is not provided"
do
- begin
- silence_stream(STDOUT) do
- config_parser = ConfigParser.new(%w(list))
- config_parser.process
- config_parser.should_receive(:exit).with(1)
- end
- rescue SystemExit => e
- e.status.should == 1
- end
- end
-
- it "should notify the user of an invalid command" do
- config_parser = ConfigParser.new(%w(sparkle))
- config_parser.should_receive(:exit).with(0)
- silence_stream(STDOUT) do
- config_parser.process
- end
- end
-
- it "should exit gracefully with bad params" do
- begin
- silence_stream(STDOUT) do
- ConfigParser.new(%w(delete --fred)).should_receive(:exit).with(1)
- end
- rescue SystemExit => e
- e.status.should == 1
- end
- end
-
- it "should set options hash for valid general options" do
- config_parser = ConfigParser.new(%w(list --user joe --password cloud --images))
- config_parser.options[:user].should == 'joe'
- config_parser.options[:password].should == 'cloud'
- config_parser.options[:subcommand].should == :images
- end
-
- it "should set options hash for valid list options" do
- config_parser = ConfigParser.new(%w(list --builds 12345))
- config_parser.options[:subcommand].should == :builds
- config_parser.options[:id].should == '12345'
- end
-
- it "should set options hash for valid build options" do
- config_parser = ConfigParser.new(%w(build --target ec2,rackspace --image 12345
--template my.tmpl))
- config_parser.options[:target].should == ['ec2','rackspace']
- config_parser.options[:image].should == '12345'
- config_parser.options[:template].should == 'my.tmpl'
- end
-
- it "should set options hash for valid push options" do
- config_parser = ConfigParser.new(%w(push --provider ec2-us-east1 --id 12345))
- config_parser.options[:provider].should == ['ec2-us-east1']
- config_parser.options[:id].should == '12345'
- end
-
- it "should set options hash for valid delete options" do
- config_parser = ConfigParser.new(%w(delete --build 12345))
- config_parser.options[:build].should == '12345'
- end
-
- it "should set options hash for valid import options" do
- config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a
--description /path/to/file --id ami-123456 --target ec2))
- config_parser.options[:provider].should == ['ec2-us-east-1a']
- config_parser.options[:target].should == ['ec2']
- config_parser.options[:description].should == '/path/to/file'
- config_parser.options[:id].should == 'ami-123456'
- end
- end
- end
-end
diff --git a/spec/import_command_spec.rb b/spec/import_command_spec.rb
deleted file mode 100644
index 9477f9e..0000000
--- a/spec/import_command_spec.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'spec_helper'
-
-module Aeolus
- module CLI
- describe ImportCommand do
- before(:each) do
- @options[:id] = "ami-test"
- @options[:target] = "ec2"
- @options[:provider] = "ec2-us-east-1"
- end
-
- describe "#import_image" do
- it "should import an image with default description values" do
- importc = ImportCommand.new(@options)
- begin
- importc.import_image
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- $stdout.string.should include("Provider Image:")
- end
-
- it "should import an image with file description" do
- @options[:description] = 'spec/sample_data/image_description.xml'
- importc = ImportCommand.new(@options)
- begin
- importc.import_image
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Target Image:")
- $stdout.string.should include("Build:")
- $stdout.string.should include("Provider Image:")
- #TODO: Add test to check that file was uploaded properly (when we have
implemented a show/view image command)
- end
- end
- end
- end
-end
diff --git a/spec/list_command_spec.rb b/spec/list_command_spec.rb
deleted file mode 100644
index 9a7bbbb..0000000
--- a/spec/list_command_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'spec_helper'
-
-module Aeolus
- module CLI
- describe ListCommand do
- end
- end
-end
diff --git a/spec/push_command_spec.rb b/spec/push_command_spec.rb
deleted file mode 100644
index 5694e76..0000000
--- a/spec/push_command_spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright 2011 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#
http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-require 'spec_helper'
-
-module Aeolus
- module CLI
- describe PushCommand do
-
- before(:each) do
- @options[:provider] = ['mock']
- @options[:user] = 'admin'
- @options[:password] = 'password'
- end
-
- describe "#run" do
- before(:each) do
- options = {}
- options[:target] = ['mock','ec2']
- options[:template] = "#{File.dirname(__FILE__)}" +
"/../examples/custom_repo.tdl"
- b = BuildCommand.new(options)
- sleep(5)
- tmpl_str = b.send(:read_file, options[:template])
- b.console.build(tmpl_str, ['mock','ec2']).each do |adaptor|
- @build_id = adaptor.image
- end
- b.console.shutdown
- @options[:id] = @build_id
- end
-
- it "should push an image with valid options" do
- p = PushCommand.new(@options, @output)
- begin
- p.run
- rescue SystemExit => e
- e.status.should == 0
- end
- $stdout.string.should include("Image:")
- $stdout.string.should include("Provider Image:")
- $stdout.string.should include("Build:")
- end
- end
-
- describe "#combo_implemented?" do
- it "should give useful feedback if no template or target is specified"
do
- @options.delete(:id)
- @options.delete(:provider)
- b = PushCommand.new(@options, @output)
- begin
- b.combo_implemented?
- rescue SystemExit => e
- e.status.should == 1
- end
- $stdout.string.should include("This combination of parameters is not
currently supported")
- end
- end
- end
- end
-end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index a268424..7cb20ca 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -21,6 +21,9 @@ require 'image'
require 'build'
require 'target_image'
require 'provider_image'
+require 'provider'
+require 'provider_type'
+require 'provider_account'
require 'config_parser'
require 'stringio'
require 'base_command'
@@ -30,6 +33,8 @@ require 'push_command'
require 'import_command'
require 'delete_command'
+require 'vcr_setup'
+
module Helpers
# Silences any stream for the duration of the block.
#
@@ -58,6 +63,11 @@ RSpec.configure do |config|
YAML::load(File.open(File.join(File.dirname(__FILE__),
"/../examples/aeolus-cli")))
end
end
+ Aeolus::CLI::BaseCommand.class_eval do
+ def handle_exception(e)
+ raise e
+ end
+ end
end
config.before(:each) do
@output = double('output')
diff --git a/spec/vcr_setup.rb b/spec/vcr_setup.rb
new file mode 100644
index 0000000..3913611
--- /dev/null
+++ b/spec/vcr_setup.rb
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2011 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at
http://www.gnu.org/copyleft/gpl.html.
+
+require 'vcr'
+
+VCR.config do |c|
+ c.cassette_library_dir = 'spec/vcr/cassettes'
+ c.stub_with :webmock
+end
\ No newline at end of file
--
1.7.6.2