Sha256: d9dd1b10d0d317a799a667b0b7aeb283d0b97d1aa1c8d1273a2e2bbb72fd8794

Contents?: true

Size: 1007 Bytes

Versions: 11

Compression:

Stored size: 1007 Bytes

Contents

require 'spec_helper'

describe Aptible::CLI::Helpers::Database do
  subject { Class.new.send(:include, described_class).new }

  describe '#validate_image_type' do
    let(:pg) do
      Fabricate(:database_image, type: 'postgresql', version: '10')
    end

    let(:redis) do
      Fabricate(:database_image, type: 'redis', version: '9.4')
    end

    let(:token) { 'some-token' }

    before do
      allow(subject).to receive(:fetch_token).and_return(token)
      allow(Aptible::Api::DatabaseImage).to receive(:all)
        .and_return([pg, redis])
    end

    it 'Raises an error if provided an invalid type' do
      bad_type = 'cassandra'
      err = "No Database Image of type \"#{bad_type}\", " \
            "valid types: #{pg.type}, #{redis.type}"
      expect do
        subject.validate_image_type(bad_type)
      end.to raise_error(Thor::Error, err)
    end

    it 'Retruns true when provided a valid type' do
      expect(subject.validate_image_type(pg.type)).to be(true)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
aptible-cli-0.24.2 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.24.1 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.24.0 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.23.0 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.22.0 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.21.0 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.20.0 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.19.9 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.19.7 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.19.6 spec/aptible/cli/helpers/database_spec.rb
aptible-cli-0.19.4 spec/aptible/cli/helpers/database_spec.rb