|
1 | 1 | describe Fastlane::Client::FirebaseAppDistributionApiClient do |
2 | 2 | let(:project_number) { 1_234_567_890 } |
3 | | - let(:app_id) { "1:1234567890:android:321abc456def7890" } |
4 | | - let(:api_client) { Fastlane::Client::FirebaseAppDistributionApiClient.new("auth_token") } |
5 | | - let(:headers) { { 'Authorization' => 'Bearer auth_token' } } |
| 3 | + let(:app_id) { '1:1234567890:android:321abc456def7890' } |
| 4 | + let(:app_name) { '1234567890/apps/1:1234567890:android:321abc456def7890' } |
| 5 | + let(:binary_path) { '/path/to/β.ipa' } |
| 6 | + let(:binary_file) { StringIO.new('binary_file') } |
| 7 | + let(:api_client) { Fastlane::Client::FirebaseAppDistributionApiClient.new('auth_token') } |
| 8 | + let(:upload_headers) { { 'Authorization' => 'Bearer auth_token', 'X-Goog-Upload-File-Name' => '%CE%B2.ipa' } } |
| 9 | + let(:udid_headers) { { 'Authorization' => 'Bearer auth_token' } } |
6 | 10 | let(:stubs) { Faraday::Adapter::Test::Stubs.new } |
7 | 11 | let(:conn) do |
8 | | - Faraday.new(url: "https://firebaseappdistribution.googleapis.com") do |b| |
| 12 | + Faraday.new(url: 'https://firebaseappdistribution.googleapis.com') do |b| |
9 | 13 | b.response(:json, parser_options: { symbolize_names: true }) |
10 | 14 | b.response(:raise_error) |
11 | 15 | b.adapter(:test, stubs) |
|
22 | 26 | Faraday.default_connection = nil |
23 | 27 | end |
24 | 28 |
|
| 29 | + describe '#upload_binary' do |
| 30 | + let(:upload) do |
| 31 | + app_name |
| 32 | + end |
| 33 | + |
| 34 | + it 'returns the long-running operation name when the upload call is successful' do |
| 35 | + allow(File).to receive(:open).with(binary_path, 'rb').and_return(binary_file) |
| 36 | + stubs.post("/upload/v1/#{app_name}/releases:upload", 'binary_file', upload_headers) do |_| |
| 37 | + [ |
| 38 | + 200, |
| 39 | + {}, # response headers |
| 40 | + { name: 'lro-name' } |
| 41 | + ] |
| 42 | + end |
| 43 | + result = api_client.upload_binary(app_name, binary_path, 'ios', 0) |
| 44 | + expect(result).to eq('lro-name') |
| 45 | + end |
| 46 | + end |
| 47 | + |
25 | 48 | describe '#get_udids' do |
26 | 49 | let(:udids) do |
27 | 50 | [ |
|
31 | 54 | end |
32 | 55 |
|
33 | 56 | it 'returns the list of UDIDs when the get call is successful' do |
34 | | - stubs.get("/v1alpha/apps/#{app_id}/testers:getTesterUdids", headers) do |_| |
| 57 | + stubs.get("/v1alpha/apps/#{app_id}/testers:getTesterUdids", udid_headers) do |_| |
35 | 58 | [ |
36 | 59 | 200, |
37 | 60 | {}, # response headers |
|
43 | 66 | end |
44 | 67 |
|
45 | 68 | it 'returns an empty list UDIDs when there are no udids' do |
46 | | - stubs.get("/v1alpha/apps/#{app_id}/testers:getTesterUdids", headers) do |_| |
| 69 | + stubs.get("/v1alpha/apps/#{app_id}/testers:getTesterUdids", udid_headers) do |_| |
47 | 70 | [ |
48 | 71 | 200, |
49 | 72 | {}, # response headers |
|
0 commit comments