Sha256: fdecd29ee9ee6de1ef8d2a5dc33208a38010d9b8cb14f88a919a7e2b8dd0066a

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require_relative 'isolated_settings_context'

# Creates an environment for each test containing a small pool of AutoNetwork
# addresses and a single "created" VM.
shared_context 'auto_network 1.x' do
  include_context 'vagrant-unit'
  include_context 'auto_network-settings'

  # Configure each testing environment to contain an AutoNetwork version 2 pool
  # file and a single existing machine that has been allocated in the pool
  let(:test_env) { isolated_environment }
  let(:pool_file) { test_env.homedir.join('auto_network', 'pool.yaml') }
  before(:each) do
    pool_file.dirname.mkpath
    pool_file.open('w+') do |f|
      f.write <<-EOF
---
poolfile_version: 2
pools:
  dummy: !ruby/object:AutoNetwork::Pool
    network_range: 10.20.1.0/29
    pool:
      10.20.1.2:
        path: #{test_env.workdir}
        name: test1
      10.20.1.3: 
      10.20.1.4: 
      10.20.1.5: 
      10.20.1.6: 
EOF
    end

    test_env.vagrantfile <<-EOF
Vagrant.configure("2") do |config|
  config.vm.define 'test1' do |node|
    node.vm.network :private_network, :auto_network => true
  end
end
EOF

    # Touch an ID file so that Vagrant thinks test1 exists. The 'dummy'
    # component of the path actually tells Vagrant which provider is managing
    # the machine. vagrant-spec defines a dummy provider for us.
    machine_dir = test_env.workdir.join('.vagrant/machines/test1/dummy')
    machine_dir.mkpath
    machine_dir.join('id').open('w+') { |f| f.write('') }
  end

  # Dispose of the temporary directory used to run the test.
  after(:each) do
    test_env.close
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-auto_network-1.0.0 spec/integration/shared/auto_network_1x_context.rb
vagrant-auto_network-1.0.0.rc1 spec/integration/shared/auto_network_1x_context.rb