]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - 3rdparty/modules/nova/spec/type/nova_aggregate_spec.rb
try again, with puppetforge modules, correctly included now
[dsa-puppet.git] / 3rdparty / modules / nova / spec / type / nova_aggregate_spec.rb
diff --git a/3rdparty/modules/nova/spec/type/nova_aggregate_spec.rb b/3rdparty/modules/nova/spec/type/nova_aggregate_spec.rb
new file mode 100644 (file)
index 0000000..dc5db97
--- /dev/null
@@ -0,0 +1,66 @@
+# run with: rspec spec/type/nova_aggregate_spec.rb
+
+require 'spec_helper'
+
+
+describe Puppet::Type.type(:nova_aggregate) do
+  before :each do
+    @provider_class = described_class.provide(:simple) do
+      mk_resource_methods
+      def create; end
+      def delete; end
+      def exists?; get(:ensure) != :absent; end
+      def flush; end
+      def self.instances; []; end
+    end
+  end
+
+  it "should be able to create an instance" do
+    described_class.new(:name => 'agg0').should_not be_nil
+  end
+
+  it "should be able to create an more complex instance" do
+    described_class.new(:name => 'agg0',
+                        :availability_zone => 'myzone',
+                        :metadata => "a=b, c=d",
+                        :hosts => "host1").should_not be_nil
+  end
+
+  it "should be able to create an more complex instance with multiple hosts" do
+    described_class.new(:name => 'agg0',
+                        :availability_zone => 'myzone',
+                        :metadata => "a=b, c=d",
+                        :hosts => "host1, host2").should_not be_nil
+  end
+
+  it "should be able to create a instance and have the default values" do
+    c = described_class.new(:name => 'agg0')
+    c[:name].should == "agg0"
+    c[:availability_zone].should == nil
+    c[:metadata].should == nil
+    c[:hosts].should == nil
+  end
+
+  it "should return the given values" do
+    c = described_class.new(:name => 'agg0',
+                            :availability_zone => 'myzone',
+                            :metadata => "  a  =  b  , c=  d  ",
+                            :hosts => "  host1, host2    ")
+    c[:name].should == "agg0"
+    c[:availability_zone].should == "myzone"
+    c[:metadata].should == {"a" => "b", "c" => "d"}
+    c[:hosts].should == ["host1" , "host2"]
+  end
+
+  it "should return the given values" do
+    c = described_class.new(:name => 'agg0',
+                            :availability_zone => "",
+                            :metadata => "",
+                            :hosts => "")
+    c[:name].should == "agg0"
+    c[:availability_zone].should == ""
+    c[:metadata].should == {}
+    c[:hosts].should == []
+  end
+
+end