mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|storage|test] Added versioning test for Files collection.
This commit is contained in:
parent
6a97b60650
commit
0287c0f7a4
1 changed files with 44 additions and 0 deletions
44
tests/aws/models/storage/files_test.rb
Normal file
44
tests/aws/models/storage/files_test.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
Fog.mock!
|
||||
|
||||
Shindo.tests("Storage[:aws] | files", [: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)
|
||||
@directory.versioning = true
|
||||
|
||||
model_tests(@directory.files, file_attributes, Fog.mocking?) do
|
||||
|
||||
v1 = @instance.version
|
||||
v2 = @directory.connection.put_object(@directory.key, @instance.key, 'version 2 content').headers['x-amz-version-id']
|
||||
v3 = @directory.connection.delete_object(@directory.key, @instance.key).headers['x-amz-version-id']
|
||||
v4 = @directory.connection.put_object(@directory.key, @instance.key, 'version 3 content').headers['x-amz-version-id']
|
||||
|
||||
tests("#get") do
|
||||
tests("#get without version fetches the latest version").returns(v4) do
|
||||
@directory.files.get(@instance.key).version
|
||||
end
|
||||
|
||||
tests("#get with version fetches that exact version").returns(v2) do
|
||||
@directory.files.get(@instance.key, 'versionId' => v2).version
|
||||
end
|
||||
|
||||
tests("#get with a deleted version returns nil").returns(nil) do
|
||||
@directory.files.get(@instance.key, 'versionId' => v3)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@directory.versions.each(&:destroy)
|
||||
@directory.destroy
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue