Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly committed Jan 22, 2010
1 parent d73a770 commit 6887296
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions examples/unit/cloudfiles_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ def cloudfiles(config = def_config, backup = def_backup)

before(:each) do
@cloudfiles = cloudfiles
@files = [4,1,3,2].to_a.map { |i| stub(o = {}).name {"aaaaa#{i}"}; o }
mock.instance_of(CloudFiles::Container).objects(:prefix => "_kind/_id/_kind-_id.") { @files }
stub(CloudFiles::Authentication).new { true }


@files = [4,1,3,2].to_a.map { |i| "aaaaa#{i}" }

@container = "container"

stub(@container).objects(:prefix => "_kind/_id/_kind-_id.") { @files }
stub(@container).delete_object(anything)

stub(CloudFiles::Connection).
new('_user', '_api_key', true, false).stub!.
container('_container') {@container}
end

it "should check [:keep, :cloudfiles]" do
Expand All @@ -49,8 +56,8 @@ def cloudfiles(config = def_config, backup = def_backup)
end

it "should delete extra files" do
mock(CloudFiles::Connection).container("_container").mock!["aaaaa1"].mock!.delete
mock(CloudFiles::Connection).container("_container").mock!["aaaaa2"].mock!.delete
mock(@container).delete_object('aaaaa1')
mock(@container).delete_object('aaaaa2')
@cloudfiles.send :cleanup
end

Expand Down
4 changes: 2 additions & 2 deletions lib/astrails/safe/cloudfiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Astrails
module Safe
class Cloudfiles < Sink
MAX_CLOUDFILES_FILE_SIZE = 5368709120

protected

def active?
Expand Down Expand Up @@ -42,7 +42,7 @@ def cleanup
puts "listing files: #{container}:#{base}*" if $_VERBOSE
cf = CloudFiles::Connection.new(user, api_key, true, service_net) unless $LOCAL
cf_container = cf.container(container)
files = cf_container.objects(:prefix => base)
files = cf_container.objects(:prefix => base).sort
print "DEBUG: Files is #{files.to_s}\n"

cleanup_with_limit(files, keep) do |f|
Expand Down

0 comments on commit 6887296

Please sign in to comment.