add test for building domain name.

This commit is contained in:
Bradley Smith
2014-07-04 11:09:00 -06:00
parent 0e9458db6c
commit 659ee41152
3 changed files with 55 additions and 0 deletions

5
spec/spec_helper.rb Normal file
View File

@@ -0,0 +1,5 @@
require 'vagrant-libvirt'
require 'support/environment_helper'
RSpec.configure do |spec|
end

View 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

View 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