require 'rspec/core/rake_task' require './lib/selbackup.rb'

RSpec::Core::RakeTask.new(:spec)

task :default => :spec

task :test_upload do

if ENV["key"] && ENV["secret"] && ENV["bucket"]
  key = ENV["key"]
  secret = ENV["secret"]
  bucket = ENV["bucket"]

  %xmkdir upload_test/tmp`
  %xbash upload_test/create_files.sh`
  sb = SelBackup.new(key, secret, bucket)
  files = Dir.glob("upload_test/tmp/*")
  files.each do | file |
    puts "Uploading: #{file}"
    sb.upload_file(file)
    %xrm #{file}`
  end
else
  puts "Usage: rake test_upload key='...' secret='...' bucket='...'"
end

end