[DRE-commits] [vagrant-libvirt] 05/163: add test for building domain name.

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:56:57 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.26
in repository vagrant-libvirt.

commit 659ee41152620000409e1972136b25a355f52e1e
Author: Bradley Smith <brad.smith at sendgrid.com>
Date:   Fri Jul 4 11:09:00 2014 -0600

    add test for building domain name.
---
 spec/spec_helper.rb                                |  5 +++
 spec/support/environment_helper.rb                 | 36 ++++++++++++++++++++++
 .../action/set_name_of_domain_spec.rb              | 14 +++++++++
 3 files changed, 55 insertions(+)

diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
new file mode 100644
index 0000000..4842086
--- /dev/null
+++ b/spec/spec_helper.rb
@@ -0,0 +1,5 @@
+require 'vagrant-libvirt'
+require 'support/environment_helper'
+
+RSpec.configure do |spec|
+end
diff --git a/spec/support/environment_helper.rb b/spec/support/environment_helper.rb
new file mode 100644
index 0000000..0e9fd89
--- /dev/null
+++ b/spec/support/environment_helper.rb
@@ -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
diff --git a/spec/vagrant-libvirt/action/set_name_of_domain_spec.rb b/spec/vagrant-libvirt/action/set_name_of_domain_spec.rb
new file mode 100644
index 0000000..a01ef03
--- /dev/null
+++ b/spec/vagrant-libvirt/action/set_name_of_domain_spec.rb
@@ -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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list