From bfc882c7e0af07c46c45f4c67ad34bd59d2f4358 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 19 Jan 2012 18:19:03 -0500 Subject: [PATCH] [aws|storage|test] Added in some file and directory model tests. --- lib/fog/aws/requests/storage/put_object.rb | 10 +++-- .../{directory_test.rb => directory_tests.rb} | 4 +- tests/aws/models/storage/file_tests.rb | 41 +++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) rename tests/aws/models/storage/{directory_test.rb => directory_tests.rb} (94%) create mode 100644 tests/aws/models/storage/file_tests.rb diff --git a/lib/fog/aws/requests/storage/put_object.rb b/lib/fog/aws/requests/storage/put_object.rb index 5cc087bc2..416bc1f8c 100644 --- a/lib/fog/aws/requests/storage/put_object.rb +++ b/lib/fog/aws/requests/storage/put_object.rb @@ -96,11 +96,13 @@ module Fog end response.headers = { - 'Content-Length' => object['Content-Length'], - 'Content-Type' => object['Content-Type'], - 'ETag' => object['ETag'], - 'Last-Modified' => object['Last-Modified'] + 'Content-Length' => object['Content-Length'], + 'Content-Type' => object['Content-Type'], + 'ETag' => object['ETag'], + 'Last-Modified' => object['Last-Modified'], } + + response.headers['x-amz-version-id'] = object['VersionId'] if object['VersionId'] != 'null' else response.status = 404 raise(Excon::Errors.status_error({:expects => 200}, response)) diff --git a/tests/aws/models/storage/directory_test.rb b/tests/aws/models/storage/directory_tests.rb similarity index 94% rename from tests/aws/models/storage/directory_test.rb rename to tests/aws/models/storage/directory_tests.rb index 31d9fe20b..e6b0b8774 100644 --- a/tests/aws/models/storage/directory_test.rb +++ b/tests/aws/models/storage/directory_tests.rb @@ -1,12 +1,12 @@ Fog.mock! -Shindo.tests("Storage[aws] | directory", [:aws]) do +Shindo.tests("Storage[:aws] | directory", [:aws]) do directory_attributes = { :key => 'fogdirectorytests' } - model_tests(Fog::Storage[:aws].directories, directory_attributes, true) do + model_tests(Fog::Storage[:aws].directories, directory_attributes, Fog.mocking?) do tests("#versioning=") do tests("#versioning=(true)").succeeds do diff --git a/tests/aws/models/storage/file_tests.rb b/tests/aws/models/storage/file_tests.rb new file mode 100644 index 000000000..dace1cb43 --- /dev/null +++ b/tests/aws/models/storage/file_tests.rb @@ -0,0 +1,41 @@ +Fog.mock! + +Shindo.tests("Storage[:aws] | file", [:aws]) do + + file_attributes = { + :key => 'fog_file_tests', + :body => lorem_file, + :public => true + } + + directory_attributes = { + :key => 'fogfilestests' + } + + @directory = Fog::Storage[:aws].directories.create(directory_attributes) + + model_tests(@directory.files, file_attributes, Fog.mocking?) do + + tests("#version") do + tests("#version should be null if versioning isn't enabled").returns(nil) do + @instance.version + end + end + + end + + @directory.versioning = true + + model_tests(@directory.files, file_attributes, Fog.mocking?) do + + tests("#version") do + tests("#version should not be null if versioning is enabled").returns(false) do + @instance.version == nil + end + end + + end + + @directory.destroy + +end