fog 0.3.15 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. data/Gemfile.lock +1 -1
  2. data/fog.gemspec +21 -11
  3. data/lib/fog.rb +1 -1
  4. data/lib/fog/core/collection.rb +1 -1
  5. data/lib/fog/rackspace/models/storage/files.rb +8 -8
  6. data/lib/fog/rackspace/requests/storage/get_object.rb +1 -1
  7. data/tests/aws/models/storage/directories_tests.rb +5 -0
  8. data/tests/aws/models/storage/directory_tests.rb +2 -6
  9. data/tests/aws/models/storage/file_tests.rb +5 -0
  10. data/tests/aws/models/storage/files_tests.rb +5 -0
  11. data/tests/google/models/storage/directories_tests.rb +5 -0
  12. data/tests/google/models/storage/directory_tests.rb +5 -0
  13. data/tests/google/models/storage/file_tests.rb +5 -0
  14. data/tests/google/models/storage/files_tests.rb +5 -0
  15. data/tests/helper.rb +10 -1
  16. data/tests/helpers/storage/directories_tests.rb +39 -0
  17. data/tests/helpers/storage/directory_tests.rb +24 -0
  18. data/tests/helpers/storage/file_tests.rb +32 -0
  19. data/tests/helpers/storage/files_tests.rb +47 -0
  20. data/tests/local/models/storage/directories_tests.rb +5 -0
  21. data/tests/local/models/storage/directory_tests.rb +5 -0
  22. data/tests/local/models/storage/file_tests.rb +5 -0
  23. data/tests/local/models/storage/files_tests.rb +5 -0
  24. data/tests/rackspace/models/storage/directories_tests.rb +5 -0
  25. data/tests/rackspace/models/storage/directory_tests.rb +5 -0
  26. data/tests/rackspace/models/storage/file_tests.rb +5 -0
  27. data/tests/rackspace/models/storage/files_tests.rb +5 -0
  28. metadata +22 -12
  29. data/spec/aws/models/storage/directories_spec.rb +0 -49
  30. data/spec/aws/models/storage/directory_spec.rb +0 -113
  31. data/spec/aws/models/storage/file_spec.rb +0 -121
  32. data/spec/aws/models/storage/files_spec.rb +0 -139
  33. data/spec/google/models/storage/directories_spec.rb +0 -49
  34. data/spec/google/models/storage/directory_spec.rb +0 -83
  35. data/spec/google/models/storage/file_spec.rb +0 -121
  36. data/spec/google/models/storage/files_spec.rb +0 -140
  37. data/tests/helpers/model_helper.rb +0 -72
@@ -1,83 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
- require File.dirname(__FILE__) + '/../../../../lib/fog/google/models/storage/directory'
3
-
4
- describe 'Fog::Google::Storage::Directory' do
5
-
6
- describe "#initialize" do
7
-
8
- it "should remap attributes from parser" do
9
- now = Time.now
10
- directory = Fog::Google::Storage::Directory.new(
11
- 'CreationDate' => now,
12
- 'Name' => 'directorykey'
13
- )
14
- directory.creation_date.should == now
15
- directory.key.should == 'directorykey'
16
- end
17
-
18
- end
19
-
20
- describe "#collection" do
21
-
22
- it "should be the directories the directory is related to" do
23
- directories = Google[:storage].directories
24
- directories.new.collection.should == directories
25
- end
26
-
27
- end
28
-
29
- describe "#destroy" do
30
-
31
- it "should return true if the directory is deleted" do
32
- directory = Google[:storage].directories.create(:key => 'fogmodeldirectory')
33
- directory.destroy.should be_true
34
- end
35
-
36
- it "should return false if the directory does not exist" do
37
- directory = Google[:storage].directories.new(:key => 'fogmodeldirectory')
38
- directory.destroy.should be_false
39
- end
40
-
41
- end
42
-
43
- describe "#reload" do
44
-
45
- before(:each) do
46
- @directory = Google[:storage].directories.create(:key => 'fogmodeldirectory')
47
- @reloaded = @directory.reload
48
- end
49
-
50
- after(:each) do
51
- @directory.destroy
52
- end
53
-
54
- it "should reset attributes to remote state" do
55
- @directory.attributes.should == @reloaded.attributes
56
- end
57
-
58
- end
59
-
60
- describe "#save" do
61
-
62
- before(:each) do
63
- @directory = Google[:storage].directories.new(:key => 'fogmodeldirectory')
64
- end
65
-
66
- it "should not exist in directories before save" do
67
- Google[:storage].directories.all.map {|directory| directory.key}.include?(@directory.key).should be_false
68
- end
69
-
70
- it "should return true when it succeeds" do
71
- @directory.save.should be_true
72
- @directory.destroy
73
- end
74
-
75
- it "should exist in directories after save" do
76
- @directory.save
77
- Google[:storage].directories.all.map {|directory| directory.key}.include?(@directory.key).should be_true
78
- @directory.destroy
79
- end
80
-
81
- end
82
-
83
- end
@@ -1,121 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe 'Fog::Google::Storage::File' do
4
-
5
- before(:each) do
6
- @directory = Google[:storage].directories.create(:key => 'fogdirectoryname')
7
- end
8
-
9
- after(:each) do
10
- @directory.destroy
11
- end
12
-
13
- describe "#initialize" do
14
-
15
- it "should remap attributes from parser" do
16
- now = Time.now
17
- directory = Fog::Google::Storage::File.new(
18
- 'Content-Length' => 10,
19
- 'Content-Type' => 'contenttype',
20
- 'Etag' => 'etag',
21
- 'Key' => 'key',
22
- 'Last-Modified' => now,
23
- 'Size' => 10,
24
- 'StorageClass' => 'storageclass'
25
- )
26
- directory.content_length == 10
27
- directory.content_type.should == 'contenttype'
28
- directory.etag.should == 'etag'
29
- directory.key.should == 'key'
30
- directory.last_modified.should == now
31
- directory.size.should == 10
32
- directory.storage_class.should == 'storageclass'
33
-
34
- directory = Fog::Google::Storage::File.new(
35
- 'ETag' => 'etag',
36
- 'LastModified' => now
37
- )
38
- directory.etag.should == 'etag'
39
- directory.last_modified.should == now
40
- end
41
-
42
- end
43
-
44
- describe "#directory" do
45
-
46
- it "should be the directory the file is related to" do
47
- @file = @directory.files.new(:key => 'foo')
48
- @file.directory.should == @directory
49
- end
50
-
51
- end
52
-
53
- describe "#copy" do
54
-
55
- it "should return a Fog::Google::Storage::File with matching attributes" do
56
- other_directory = Google[:storage].directories.create(:key => 'fogotherdirectoryname')
57
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
58
- file = @directory.files.create(:key => 'fogfilename', :body => data)
59
- other_file = file.copy('fogotherdirectoryname', 'fogotherfilename')
60
- file.reload.attributes.reject{|key,value| [:key, :last_modified].include?(key)}.should == other_file.reload.attributes.reject{|key,value| [:key, :last_modified].include?(key)}
61
- other_file.destroy
62
- file.destroy
63
- other_directory.destroy
64
- end
65
-
66
- end
67
-
68
- describe "#destroy" do
69
-
70
- it "should return true if the file is deleted" do
71
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
72
- file = @directory.files.create(:key => 'fogfilename', :body => data)
73
- file.destroy.should be_true
74
- end
75
-
76
- it "should return true if the file does not exist" do
77
- file = @directory.files.new(:key => 'fogfilename')
78
- file.destroy.should be_true
79
- end
80
-
81
- end
82
-
83
- describe "#reload" do
84
-
85
- it "should reset attributes to remote state" do
86
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
87
- file = @directory.files.create(:key => 'fogfilename', :body => data)
88
- file.last_modified = Time.now
89
- file.reload.attributes.should == file.attributes
90
- file.destroy
91
- end
92
-
93
- end
94
-
95
- describe "#save" do
96
-
97
- it "should return the success value" do
98
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
99
- file = @directory.files.new(:key => 'fogfilename', :body => data)
100
- file.save.should be_true
101
- file.destroy
102
- end
103
-
104
- end
105
-
106
- # describe "#url" do
107
- #
108
- # it "should return a signed expiring url" do
109
- # data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
110
- # file = @directory.files.create(:key => 'fogfilename', :body => data)
111
- # url = file.url(Time.now + 60 * 10)
112
- # url.should include("fogfilename", "Expires")
113
- # unless Fog.mocking?
114
- # open(url).read.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
115
- # end
116
- # file.destroy
117
- # end
118
- #
119
- # end
120
-
121
- end
@@ -1,140 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
- require 'pp'
3
-
4
- describe 'Fog::Google::Storage::Files' do
5
-
6
- before(:each) do
7
- dirname = "fogdirname"
8
- # dirname = "fog#{Time.now.to_f}"
9
- @directory = Google[:storage].directories.create(:key => dirname)
10
- end
11
-
12
- after(:each) do
13
- until @directory.files.reload.empty?
14
- @directory.files.each {|file| file.destroy}
15
- end
16
- @directory.destroy
17
- end
18
-
19
- describe "#initialize" do
20
-
21
- it "should remap attributes from parser" do
22
- files = Fog::Google::Storage::Files.new(
23
- 'IsTruncated' => true,
24
- 'Marker' => 'marker',
25
- 'MaxKeys' => 1,
26
- 'Prefix' => 'prefix'
27
- )
28
- files.is_truncated.should == true
29
- files.marker.should == 'marker'
30
- files.max_keys.should == 1
31
- files.prefix.should == 'prefix'
32
- end
33
-
34
- end
35
-
36
- describe "#all" do
37
-
38
- it "should return nil if the directory does not exist" do
39
- directory = Google[:storage].directories.new(:key => 'notadirectory')
40
- directory.files.all.should be_nil
41
- end
42
-
43
- it "should return 10 files and report truncated" do
44
- 10.times do |n|
45
- @directory.files.create(:key => "file-#{n}")
46
- end
47
- response = @directory.files.all
48
- response.should have(10).items
49
- response.is_truncated.should_not be_true
50
- end
51
-
52
- # it "should limit the max_keys to 10" do
53
- # 10.times do |n|
54
- # @directory.files.create(:key => "file-#{n}")
55
- # end
56
- # response = @directory.files.all(:max_keys => 20)
57
- # response.should have(10).items
58
- # response.max_keys.should == 20
59
- # response.is_truncated.should be_true
60
- # end
61
-
62
- end
63
-
64
- describe "#create" do
65
-
66
- it "should exist on google storage" do
67
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
68
- file = @directory.files.create(:key => 'fogfilename', :body => data)
69
- @directory.files.get('fogfilename').should_not be_nil
70
- file.destroy
71
- end
72
-
73
- end
74
-
75
- describe "#get" do
76
-
77
- before(:each) do
78
- @data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
79
- @file = @directory.files.create(:key => 'fogfilename', :body => @data)
80
- end
81
-
82
- after(:each) do
83
- @file.destroy
84
- end
85
-
86
- it "should return a Fog::Google::Storage::File with metadata and data" do
87
- @file.reload
88
- @file.body.should_not be_nil
89
- # @file.content_length.should_not be_nil
90
- @file.etag.should_not be_nil
91
- @file.last_modified.should_not be_nil
92
- @file.destroy
93
- end
94
-
95
- it "should return chunked data if given a block" do
96
- data = ''
97
- @directory.files.get('fogfilename') do |chunk|
98
- data << chunk
99
- end
100
- data.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
101
- end
102
-
103
- end
104
-
105
- describe "#get_url" do
106
-
107
- it "should return a url" do
108
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
109
- file = @directory.files.create(:acl => 'public-read', :key => 'fogfilename', :body => data)
110
- url = @directory.files.get_url('fogfilename', Time.now + 60 * 10)
111
- unless Fog.mocking?
112
- open(url).read.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
113
- end
114
- file.destroy
115
- end
116
-
117
- end
118
-
119
- describe "#head" do
120
-
121
- it "should return a Fog::Google::Storage::File with metadata" do
122
- data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
123
- file = @directory.files.create(:key => 'fogfilename', :body => data)
124
- file = @directory.files.get('fogfilename')
125
- file.etag.should_not be_nil
126
- file.last_modified.should_not be_nil
127
- file.destroy
128
- end
129
-
130
- end
131
-
132
- describe "#reload" do
133
-
134
- it "should reload data" do
135
- @directory.files.reload.should == @directory.files
136
- end
137
-
138
- end
139
-
140
- end
@@ -1,72 +0,0 @@
1
- def tests_model
2
- tests_model_first
3
- tests_collection
4
- tests_model_last
5
- end
6
-
7
- def tests_model_first
8
-
9
- tests(@model.class) do
10
-
11
- test('#save') do
12
- @model.save
13
- end
14
-
15
- if @model.respond_to?(:ready?)
16
- @model.wait_for { ready? }
17
- end
18
-
19
- test('#reload') do
20
- reloaded = @model.reload
21
- @model.attributes == reloaded.attributes
22
- end
23
-
24
- end
25
-
26
- end
27
-
28
- def tests_collection
29
-
30
- tests(@collection.class) do
31
-
32
- test('collection#all includes persisted models') do
33
- @collection.all.map {|model| model.identity}.include?(@model.identity)
34
- end
35
-
36
- tests('collection#get') do
37
-
38
- test 'should return a matching model if one exists' do
39
- get = @collection.get(@model.identity)
40
- @model.attributes == get.attributes
41
- end
42
-
43
- test 'should return nil if no matching model exists' do
44
- !@collection.get(@non_id)
45
- end
46
-
47
- end
48
-
49
- test('collection#reload') do
50
- @collection.all
51
- reloaded = @collection.reload
52
- @collection.attributes == reloaded.attributes
53
- end
54
-
55
- end
56
-
57
- end
58
-
59
- def tests_model_last
60
-
61
- tests(@model.class) do
62
-
63
- test('#destroy') do
64
- if @model.respond_to?(:ready?)
65
- @model.wait_for{ ready? }
66
- end
67
- @model.destroy
68
- end
69
-
70
- end
71
-
72
- end