]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - 3rdparty/modules/rabbitmq/spec/unit/puppet/provider/rabbitmq_vhost/rabbitmqctl_spec.rb
move to puppetlabs rabbitmq module
[dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / puppet / provider / rabbitmq_vhost / rabbitmqctl_spec.rb
diff --git a/3rdparty/modules/rabbitmq/spec/unit/puppet/provider/rabbitmq_vhost/rabbitmqctl_spec.rb b/3rdparty/modules/rabbitmq/spec/unit/puppet/provider/rabbitmq_vhost/rabbitmqctl_spec.rb
new file mode 100644 (file)
index 0000000..6c8cce8
--- /dev/null
@@ -0,0 +1,45 @@
+require 'puppet'
+require 'mocha'
+RSpec.configure do |config|
+  config.mock_with :mocha
+end
+provider_class = Puppet::Type.type(:rabbitmq_vhost).provider(:rabbitmqctl)
+describe provider_class do
+  before :each do
+    @resource = Puppet::Type::Rabbitmq_vhost.new(
+      {:name => 'foo'}
+    )
+    @provider = provider_class.new(@resource)
+  end
+  it 'should match vhost names' do
+    @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
+Listing vhosts ...
+foo
+...done.
+EOT
+    @provider.exists?.should == 'foo'
+  end
+  it 'should not match if no vhosts on system' do
+    @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
+Listing vhosts ...
+...done.
+EOT
+    @provider.exists?.should be_nil
+  end
+  it 'should not match if no matching vhosts on system' do
+    @provider.expects(:rabbitmqctl).with('-q', 'list_vhosts').returns <<-EOT
+Listing vhosts ...
+fooey
+...done.
+EOT
+    @provider.exists?.should be_nil
+  end
+  it 'should call rabbitmqctl to create' do
+    @provider.expects(:rabbitmqctl).with('add_vhost', 'foo')
+    @provider.create
+  end
+  it 'should call rabbitmqctl to create' do
+    @provider.expects(:rabbitmqctl).with('delete_vhost', 'foo')
+    @provider.destroy
+  end
+end