require 'spec_helper'
require 'providers/aws/aws_connector'

RSpec.describe Devops::Model::AwsProviderAccount, type: :model do
  let(:provider_account) { build(:aws_provider_account) }


  describe 'validation rules' do
    it 'is valid with valid attrs' do
      expect(provider_account).to be_valid
    end

    include_examples 'field type validation', :account_name, :not_nil, :non_empty_string
    include_examples 'field type validation', :description, :maybe_nil
    include_examples 'field type validation', :ssh_key, :not_nil, :non_empty_string
    include_examples 'field type validation', :access_key_id, :not_nil, :non_empty_string
    include_examples 'field type validation', :secret_access_key, :not_nil, :non_empty_string

    it "isn't valid if description length is more than 500" do
      provider_account.description = 'a' * 501
      expect(provider_account).not_to be_valid
    end

    pending "isn't valid if keys collection doesn't include given key" do
      expect(provider_account).not_to be_valid
    end
  end

  describe '#initialize' do
    pending 'sets provider to aws' do
      expect(build(:aws_provider_account, provider: nil).provider).to eq 'aws'
    end
  end
end