mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
add test for building domain name.
This commit is contained in:
5
spec/spec_helper.rb
Normal file
5
spec/spec_helper.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'vagrant-libvirt'
|
||||
require 'support/environment_helper'
|
||||
|
||||
RSpec.configure do |spec|
|
||||
end
|
||||
36
spec/support/environment_helper.rb
Normal file
36
spec/support/environment_helper.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
require "ostruct"
|
||||
require "pathname"
|
||||
|
||||
class EnvironmentHelper
|
||||
|
||||
attr_writer :default_prefix
|
||||
|
||||
def [](value)
|
||||
self.send(value.to_sym)
|
||||
end
|
||||
|
||||
def machine
|
||||
self
|
||||
end
|
||||
|
||||
def provider_config
|
||||
self
|
||||
end
|
||||
|
||||
def default_prefix
|
||||
# noop
|
||||
end
|
||||
|
||||
def root_path
|
||||
Pathname.new("./spec/support/foo")
|
||||
end
|
||||
|
||||
def domain_name
|
||||
#noop
|
||||
end
|
||||
|
||||
def libvirt_compute
|
||||
OpenStruct.new(servers: [])
|
||||
end
|
||||
|
||||
end
|
||||
14
spec/vagrant-libvirt/action/set_name_of_domain_spec.rb
Normal file
14
spec/vagrant-libvirt/action/set_name_of_domain_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
|
||||
before :each do
|
||||
@env = EnvironmentHelper.new
|
||||
end
|
||||
|
||||
it "builds uniqie domain name" do
|
||||
dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
|
||||
first = dmn.build_domain_name(@env)
|
||||
second = dmn.build_domain_name(@env)
|
||||
first.should_not eq(second)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user