You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2013/03/14 19:19:03 UTC

[14/15] git commit: CIMI: a very simple test of volume creation

CIMI: a very simple test of volume creation


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/946ddfe8
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/946ddfe8
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/946ddfe8

Branch: refs/heads/master
Commit: 946ddfe8108619989e744686fb731564980267be
Parents: 66e0fae
Author: David Lutterkort <lu...@redhat.com>
Authored: Mon Mar 11 15:53:14 2013 -0700
Committer: David Lutterkort <lu...@redhat.com>
Committed: Wed Mar 13 17:28:13 2013 -0700

----------------------------------------------------------------------
 server/tests/cimi/collections/volumes_test.rb |   42 ++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/946ddfe8/server/tests/cimi/collections/volumes_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/cimi/collections/volumes_test.rb b/server/tests/cimi/collections/volumes_test.rb
new file mode 100644
index 0000000..0b55d06
--- /dev/null
+++ b/server/tests/cimi/collections/volumes_test.rb
@@ -0,0 +1,42 @@
+require 'rubygems'
+require 'require_relative' if RUBY_VERSION < '1.9'
+require 'minitest/autorun'
+require_relative './common.rb'
+
+describe CIMI::Collections::Volumes do
+
+  def create_model(model_class, attr)
+    model = model_class.new(attr)
+    svc_class = CIMI::Service::const_get(model_class.name.split('::').last)
+    svc_class.new(nil, :model => model).save
+    model
+  end
+
+  before do
+    def app; run_frontend(:cimi) end
+    authorize 'mockuser', 'mockpassword'
+
+    @config = create_model CIMI::Model::VolumeConfiguration,
+      :id => "http://localhost:3001/cimi/volume_configurations/1",
+      :name => "volume_config",
+      :format => "ext3",
+      :capacity => 1
+
+    @collection = CIMI::Collections.collection(:volumes)
+  end
+
+  def make_volume_create
+    vt = CIMI::Model::VolumeTemplate.new
+    vt.volume_config.href = @config.id
+    CIMI::Model::VolumeCreate.new(:name => "new_cimi_volume_#{Time.now.to_i}",
+         :volume_template => vt)
+  end
+
+  it 'allows creation of a new volume' do
+    vc = make_volume_create
+    post '/cimi/volumes', vc.to_json, "CONTENT_TYPE" => "application/json"
+
+    last_response.status.must_equal 201
+    model.name.must_equal vc.name
+  end
+end