incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jprov...@redhat.com
Subject [PATCH aggregator 4/5] fixed tests
Date Tue, 14 Sep 2010 15:53:47 GMT
From: Jan Provaznik <jprovazn@redhat.com>

TBD: add template test
---
 src/spec/factories/image.rb      |   10 ++-----
 src/spec/factories/instance.rb   |    2 +-
 src/spec/factories/template.rb   |   21 +++++++++++++++++
 src/spec/models/image_spec.rb    |   47 +++----------------------------------
 src/spec/models/instance_spec.rb |    6 ++--
 5 files changed, 32 insertions(+), 54 deletions(-)
 create mode 100644 src/spec/factories/template.rb

diff --git a/src/spec/factories/image.rb b/src/spec/factories/image.rb
index cc0bc17..293ac22 100644
--- a/src/spec/factories/image.rb
+++ b/src/spec/factories/image.rb
@@ -3,11 +3,7 @@
 
 Factory.define :image do |i|
   i.sequence(:name) { |n| "image#{n}" }
-  i.sequence(:external_key) { |n| "key#{n}" }
-  i.architecture 'i686'
-  i.provider { |p| Provider.new }
-end
-
-Factory.define :front_end_image, :parent => :image do |i|
-  i.provider nil
+  i.status 'queued'
+  i.target 'ec2'
+  i.association(:template)
 end
diff --git a/src/spec/factories/instance.rb b/src/spec/factories/instance.rb
index 7533c64..3dc37e9 100644
--- a/src/spec/factories/instance.rb
+++ b/src/spec/factories/instance.rb
@@ -3,7 +3,7 @@ Factory.define :instance do |i|
   i.sequence(:external_key) { |n| "key#{n}" }
   i.association :hardware_profile, :factory => :mock_hwp1
   i.association :cloud_account, :factory => :mock_cloud_account
-  i.association :image, :factory => :image
+  i.association :template, :factory => :template
   i.association :pool, :factory => :pool
   i.state "running"
 end
diff --git a/src/spec/factories/template.rb b/src/spec/factories/template.rb
new file mode 100644
index 0000000..4774148
--- /dev/null
+++ b/src/spec/factories/template.rb
@@ -0,0 +1,21 @@
+Factory.define :template do |i|
+  i.sequence(:name) { |n| "template#{n}" }
+  i.xml <<EOF
+<image>
+  <name>tpl</name>
+  <repos>
+    <repo>https://localhost/pulp/repos/jboss2</repo>
+  </repos>
+  <os>fedora</os>
+  <description/>
+  <services/>
+  <groups>
+    <group>JBoss Core Packages</group>
+  </groups>
+  <packages>
+    <package><name>jboss-as5</name><group>JBoss Core Packages</group></package>
+    <package><name>jboss-jgroups</name><group>JBoss Core Packages</group></package>
+  </packages>
+</image>
+EOF
+end
diff --git a/src/spec/models/image_spec.rb b/src/spec/models/image_spec.rb
index a0fd8ca..ad9ca45 100644
--- a/src/spec/models/image_spec.rb
+++ b/src/spec/models/image_spec.rb
@@ -2,20 +2,7 @@ require 'spec_helper'
 
 describe Image do
   before(:each) do
-    @provider = Factory.build(:mock_provider)
     @client = mock('DeltaCloud', :null_object => true)
-    @provider.stub!(:connect).and_return(@client)
-  end
-
-  it "should have a unique external key" do
-    i1 = Factory.create(:image, :provider => @provider)
-    i2 = Factory.create(:image, :provider => @provider)
-    @provider.images = [i1, i2]
-    i1.should be_valid
-    i2.should be_valid
-
-    i2.external_key = i1.external_key
-    i2.should_not be_valid
   end
 
   it "should have a name" do
@@ -38,36 +25,10 @@ describe Image do
     i.should be_valid
   end
 
-  it "should have an architecture if it has a provider" do
-    i = Factory.build(:image, :architecture => nil)
-    i.should_not be_valid
-
-    i.architecture = 'i686'
-    i.should be_valid
-  end
-
-  it "should have provider images only if it has a provider" do
-    i = Factory.create(:image, :provider => nil)
-
-    i.aggregator_images << i
-    i.should have(1).error_on(:aggregator_images)
-    i.errors.on(:aggregator_images).should eql(
-      "Aggregator image only allowed for provider images")
-
-    i.aggregator_images.clear
-    i.should be_valid
-  end
-
-  it "should have aggregator images only if it has a pool" do
-    i = Factory.create(:image)
-
-    i.provider_images << i
-    i.should have(1).error_on(:provider_images)
-    i.errors.on(:provider_images).should eql(
-      "Provider images only allowed for aggregator images")
-
-    i.provider_images.clear
-    i.should be_valid
+  it "should have automatically generated uuid after save" do
+    i = Factory.build(:image)
+    i.save
+    i.uuid.should_not be_nil
   end
 
 end
diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb
index 16e8eb9..49bf625 100644
--- a/src/spec/models/instance_spec.rb
+++ b/src/spec/models/instance_spec.rb
@@ -24,11 +24,11 @@ describe Instance do
     @instance.should be_valid
   end
 
-  it "should require image to be set" do
-    @instance.image_id = nil
+  it "should require template to be set" do
+    @instance.template_id = nil
     @instance.should_not be_valid
 
-    @instance.image_id = 1
+    @instance.template_id = 1
     @instance.should be_valid
   end
 
-- 
1.7.2.2


Mime
View raw message