Skip to content

Instantly share code, notes, and snippets.

@sauceaaron
Last active May 23, 2017 15:02
Show Gist options
  • Save sauceaaron/391bd20705674d3b175af5b8bca6e6a3 to your computer and use it in GitHub Desktop.
Save sauceaaron/391bd20705674d3b175af5b8bca6e6a3 to your computer and use it in GitHub Desktop.
check that file is uploaded to sauce labs
#!/usr/bin/env ruby
require "digest/md5"
require "sauce_whisk"
# specify the file to upload
local_file_path = "/tmp/foo.apk"
# get file name and checksum to use later
file_name = File.basename(local_file_path)
file_md5 = Digest::MD5.file(local_file_path).hexdigest
puts "upload #{local_file_path} with md5 #{file_md5}"
# create sauce storage instance
storage = SauceWhisk::Storage.new :debug => true
# upload file to sauce storage and fail if not successful
uploaded = storage.upload(local_file_path)
if uploaded == false
puts "file did not successfully upload"
exit 1
end
## or ##
# check for file in sauce storage and fail if it is not already there
found = storage.files.select { |file| file["name"] == file_name && file["md5"] == file_md5 }
if found.length != 1
puts "file has not been found in sauce storage"
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment