Class: Fastlane::Helper::TestdroidRunnerHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::TestdroidRunnerHelper
- Defined in:
- lib/fastlane/plugin/testdroid_runner/helper/shared.rb
Class Method Summary collapse
Class Method Details
.get_os(params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/plugin/testdroid_runner/helper/shared.rb', line 14 def self.get_os(params) if params[:application_file].end_with?(".apk") return { name: "ANDROID", framework: "s_osType_eq_ANDROID;s_name_like_%Instrumentation", extname: "apk" } end if params[:application_file].end_with?(".ipa", ".app") # XCTest would be return { name: "IOS", framework: "s_osType_eq_IOS;s_name_like_%XCTest", extname: "ipa" } return { name: "IOS", framework: "s_osType_eq_IOS;s_name_like_%XCUITest", extname: "ipa" } end raise "Unknown extension for #{params.application_file}" end |
.get_user(params) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/fastlane/plugin/testdroid_runner/helper/shared.rb', line 6 def self.get_user(params) if @user.nil? client = TestdroidAPI::ApikeyClient.new(params[:api_key]) @user = client. end @user end |
.upload_file(file, access_group = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fastlane/plugin/testdroid_runner/helper/shared.rb', line 25 def self.upload_file(file, access_group = nil) unless File.exist?(file) raise "[testdroid] File #{file} doesn't exist" end file_name = File.basename(file) duplicated_files = @user.files.list({ filter: "s_name_eq_#{file_name}" }) unless duplicated_files.nil? || duplicated_files.length == 0 puts("[testdroid] Deleting duplicated files with ids: #{duplicated_files.collect(&:id)}") duplicated_files.each(&:delete) end uploaded_file = @user.files.upload(file) if uploaded_file.nil? raise "[testdroid] Error uploading file" end puts("[testdroid] Uploaded: #{uploaded_file.id}") unless access_group.nil? group = @user.instance_variable_get(:@client).get('/cloud/api/v2/me/access-groups', { limit: 10, search: access_group }) if group['data'].nil? raise "[testdroid] Access Group #{access_group} not found" end unless group['data'].count == 1 raise "[testdroid] Too many access groups found for #{access_group}: #{group['data'].count}" end group_id = group['data'][0]['id'] @user.instance_variable_get(:@client).post("/cloud/api/v2/me/files/#{uploaded_file.id}/share", { accessGroupId: group_id }) end uploaded_file end |