Sha256: 351cdb88e031ffe5384d65171f2021d807f54a86176718481a8083ce3b464205

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'
require 'profitbricks_lan_delete'

Chef::Knife::ProfitbricksLanDelete.load_deps

describe Chef::Knife::ProfitbricksLanDelete do
  subject { Chef::Knife::ProfitbricksLanDelete.new }

  before :each do
    {
      name: 'Chef Test',
      public: 'true'
    }.each do |key, value|
      Chef::Config[:knife][key] = value
    end

    ProfitBricks.configure do |config|
      config.username = Chef::Config[:knife][:profitbricks_username]
      config.password = Chef::Config[:knife][:profitbricks_password]
      config.url = Chef::Config[:knife][:profitbricks_url]
      config.debug = Chef::Config[:knife][:profitbricks_debug] || false
      config.global_classes = false
    end

    @datacenter = ProfitBricks::Datacenter.create(name: 'Chef test',
                                                  description: 'Chef test datacenter',
                                                  location: 'us/las')
    @datacenter.wait_for { ready? }

    @lan = ProfitBricks::LAN.create(@datacenter.id, name: 'Chef Test',
                                                    public: 'true')
    @lan.wait_for { ready? }

    Chef::Config[:knife][:datacenter_id] = @datacenter.id
    subject.config[:yes] = true

    allow(subject).to receive(:puts)
  end

  after :each do
    ProfitBricks.configure do |config|
      config.username = Chef::Config[:knife][:profitbricks_username]
      config.password = Chef::Config[:knife][:profitbricks_password]
      config.url = Chef::Config[:knife][:profitbricks_url]
      config.debug = Chef::Config[:knife][:profitbricks_debug] || false
      config.global_classes = false
    end

    @datacenter.delete
    @datacenter.wait_for { ready? }
  end

  describe '#run' do
    it 'should delete a lan' do
      subject.run
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife-profitbricks-2.0.1 spec/chef/knife/profitbricks_lan_delete_spec.rb