spec/vcloud/tools/tester/test_parameters_spec.rb in vcloud-tools-tester-0.0.6 vs spec/vcloud/tools/tester/test_parameters_spec.rb in vcloud-tools-tester-0.1.0
- old
+ new
@@ -1,106 +1,58 @@
+require 'spec_helper'
require 'vcloud/tools/tester'
-module Vcloud::Tools::Tester
+describe Vcloud::Tools::Tester::TestParameters do
+ before(:all) do
+ @data_dir = File.join(File.dirname(__FILE__), "/data")
+ end
- describe TestParameters do
+ subject(:parameters) do
+ Vcloud::Tools::Tester::TestParameters.new(user_params, fixture_params)
+ end
- before(:all) do
- @data_dir = File.join(File.dirname(__FILE__), "/data")
+ let(:config_file) { "#{@data_dir}/test_launcher_config.yaml" }
+ let(:vdc_1_name) { "launcher-vdc-1-name" }
+ let(:network_1_id) { "12345678-1234-1234-1234-000000111111" }
+ let(:user_params) {
+ {
+ :vdc_1_name => vdc_1_name,
+ }
+ }
+ let(:fixture_params) {
+ {
+ :network_1_id => network_1_id,
+ }
+ }
+
+ context "parameters required for integration tests" do
+ it "gives a useful error when the parameter is not set" do
+ expect{parameters.doesnotexist}.to raise_error("Method TestParameters#doesnotexist not defined")
end
- context "loading config file" do
+ it "returns the correct value for the user-defined parameters" do
+ test_vdc_1_name = parameters.vdc_1_name
+ expect(test_vdc_1_name).to eq(vdc_1_name)
+ end
- it "loads input yaml when intialized" do
- stub_const('ENV', {'FOG_CREDENTIAL' => 'test-organisation'})
- parameters = TestParameters.new("#{@data_dir}/test_config.yaml")
- test_vdc = parameters.vdc_1_name
- expect(test_vdc).to eq("test-vdc-name")
- end
+ it "returns the correct value for the fixture parameters" do
+ test_network_1_id = parameters.network_1_id
+ expect(test_network_1_id).to eq(network_1_id)
+ end
+ end
- it "loads a different organization's yaml when env var changes" do
- stub_const('ENV', {'FOG_CREDENTIAL' => 'other-organisation'})
- parameters = TestParameters.new("#{@data_dir}/test_config.yaml")
- test_vdc = parameters.vdc_1_name
- expect(test_vdc).to eq("other-vdc-name")
+ context "sanity checks" do
+ context "no user-defined parameters passed in" do
+ let(:user_params) {{}}
+ it "raises an error if it receives no user-defined parameters" do
+ expect{ parameters }.to raise_error("No user parameters received")
end
-
- it "input yaml file can be changed" do
- stub_const('ENV', {'FOG_CREDENTIAL' => 'minimal-organisation'})
- parameters = TestParameters.new("#{@data_dir}/test_minimal_config.yaml")
- test_vdc = parameters.vdc_1_name
- expect(test_vdc).to eq("minimal-vdc-name")
- end
-
- it "gives a useful error when FOG_CREDENTIAL is unset" do
- stub_const('ENV', {})
- expect {
- TestParameters.new("#{@data_dir}/test_minimal_config.yaml")
- }.to raise_error(RuntimeError, /Must set FOG_CREDENTIAL envvar/)
- end
-
- it "gives a useful error when the FOG_CREDENTIAL is missing from the config" do
- stub_const('ENV', {'FOG_CREDENTIAL' => 'bogus-fog-credential'})
- expect {
- TestParameters.new("#{@data_dir}/test_config.yaml")
- }.to raise_error(RuntimeError, /Invalid FOG_CREDENTIAL value/)
- end
-
- it "gives a useful error when there is no config file" do
- stub_const('ENV', {'FOG_CREDENTIAL' => 'minimal-organisation'})
- expect {
- TestParameters.new("#{@data_dir}/non_existent_testing_config.yaml")
- }.to raise_error(ArgumentError, /Missing required file/)
- end
-
end
- context "parameters required for integration tests" do
-
- it "contains all the parameters required for the vCloud Launcher tests" do
- ENV['FOG_CREDENTIAL'] = "launcher-testing-organisation"
- parameters = TestParameters.new("#{@data_dir}/test_launcher_config.yaml")
-
- test_vdc_1_name = parameters.vdc_1_name
- expect(test_vdc_1_name).to eq("launcher-vdc-1-name")
-
- test_vdc_2_name = parameters.vdc_2_name
- expect(test_vdc_2_name).to eq("launcher-vdc-2-name")
-
- test_catalog = parameters.catalog
- expect(test_catalog).to eq("launcher-catalog")
-
- test_vapp_template = parameters.vapp_template
- expect(test_vapp_template).to eq("launcher-vapp-template")
-
- test_network_1 = parameters.network_1
- expect(test_network_1).to eq("launcher-network-1")
-
- test_network_1_ip = parameters.network_1_ip
- expect(test_network_1_ip).to eq("launcher-network-1-ip")
-
- test_network_2 = parameters.network_2
- expect(test_network_2).to eq("launcher-network-2")
-
- test_network_2_ip = parameters.network_2_ip
- expect(test_network_2_ip).to eq("launcher-network-2-ip")
-
- test_storage_profile = parameters.storage_profile
- expect(test_storage_profile).to eq("launcher-storage-profile")
-
- test_default_storage_profile_name = parameters.default_storage_profile_name
- expect(test_default_storage_profile_name).to eq("launcher-default-sp-name")
-
- test_default_storage_profile_href = parameters.default_storage_profile_href
- expect(test_default_storage_profile_href).to eq("launcher-default-sp-href")
-
- test_vdc_1_storage_profile_href = parameters.vdc_1_storage_profile_href
- expect(test_vdc_1_storage_profile_href).to eq("launcher-vdc-1-sp-href")
-
- test_vdc_2_storage_profile_href = parameters.vdc_2_storage_profile_href
- expect(test_vdc_2_storage_profile_href).to eq("launcher-vdc-2-sp-href")
+ context "no fixture parameters passed in" do
+ let(:fixture_params) {{}}
+ it "raises an error if it receives no fixture parameters" do
+ expect{ parameters }.to raise_error("No fixture parameters received")
end
-
end
-
end
end