CID-508: add specs for provider_account validation

This commit is contained in:
Anton Chuchkalov 2016-04-18 21:24:26 +03:00
parent 56b7c914d1
commit 05fa1d323f
2 changed files with 30 additions and 1 deletions

View File

@ -29,6 +29,21 @@ RSpec.describe Devops::Model::DeployEnvEc2, type: :model do
env.validate!
}.to raise_error Devops::NonExistingUser
end
it "isn't valid if provider_account isn't present" do
allow(stubbed_connector).to receive(:provider_accounts) do |provider|
if provider == 'ec2'
account_name = 'ec2_account'
else
account_name = 'static_account'
end
[Provider::ProviderFactory.get_account_class(provider).new('account_name' => account_name)]
end
env.provider_account = 'static_account'
expect(env).not_to be_valid
env.provider_account = 'ec2_account'
expect(env).to be_valid
end
end
describe '#initialize' do

View File

@ -12,8 +12,22 @@ RSpec.describe Devops::Model::DeployEnvStatic, type: :model do
end
it_behaves_like 'deploy env'
end
it "isn't valid if provider_account isn't present" do
allow(stubbed_connector).to receive(:provider_accounts) do |provider|
if provider == 'ec2'
account_name = 'ec2_account'
else
account_name = 'static_account'
end
[Provider::ProviderFactory.get_account_class(provider).new('account_name' => account_name)]
end
env.provider_account = 'ec2_account'
expect(env).not_to be_valid
env.provider_account = 'static_account'
expect(env).to be_valid
end
end
describe '.create' do
it 'returns instance of DeployEnvStatic' do