forked from fastlane/fastlane
-
Notifications
You must be signed in to change notification settings - Fork 3
/
runner_spec.rb
148 lines (129 loc) 路 4.71 KB
/
runner_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
require 'deliver/runner'
class MockSession
def teams
[
{ 'contentProvider' => { 'contentProviderId' => 'abc', 'name' => 'A B C' } },
{ 'contentProvider' => { 'contentProviderId' => 'def', 'name' => 'D E F' } }
]
end
def team_id
'abc'
end
def csrf_tokens
nil
end
end
class MockTransporter
def provider_ids
{
'A B C' => 'abc',
'D E F' => 'somelegacything'
}
end
end
describe Deliver::Runner do
let(:runner) do
allow(Spaceship::ConnectAPI).to receive(:login).and_return(true)
allow(Spaceship::ConnectAPI).to receive(:select_team).and_return(true)
allow(Spaceship::Tunes).to receive(:client).and_return(MockSession.new)
allow_any_instance_of(Deliver::DetectValues).to receive(:run!) { |opt| opt }
Deliver::Runner.new(options)
end
let(:options) do
# A typical options hash expected from Deliver::DetectValues
{
username: 'bill@acme.com',
ipa: 'ACME.ipa',
app_identifier: 'com.acme.acme',
app_version: '1.0.7',
platform: 'ios'
}
end
before do
allow(Deliver).to receive(:cache).and_return({
app: double('app', { id: 'YI8C2AS' })
})
end
describe :upload_binary do
let(:transporter) { MockTransporter.new }
before do
allow(FastlaneCore::ItunesTransporter).to receive(:new).and_return(transporter)
end
describe 'with an IPA file for iOS' do
it 'uploads the IPA for the iOS platform' do
expect_any_instance_of(FastlaneCore::IpaUploadPackageBuilder).to receive(:generate)
.with(app_id: 'YI8C2AS', ipa_path: 'ACME.ipa', package_path: '/tmp', platform: 'ios')
.and_return('path')
expect(transporter).to receive(:upload).with(package_path: 'path', asset_path: 'ACME.ipa', platform: 'ios').and_return(true)
runner.upload_binary
end
end
describe 'with an IPA file for tvOS' do
before do
options[:platform] = 'appletvos'
end
it 'uploads the IPA for the tvOS platform' do
expect_any_instance_of(FastlaneCore::IpaUploadPackageBuilder).to receive(:generate)
.with(app_id: 'YI8C2AS', ipa_path: 'ACME.ipa', package_path: '/tmp', platform: 'appletvos')
.and_return('path')
expect(transporter).to receive(:upload).with(package_path: 'path', asset_path: 'ACME.ipa', platform: 'appletvos').and_return(true)
runner.upload_binary
end
end
describe 'with a PKG file for macOS' do
before do
options[:platform] = 'osx'
options[:pkg] = 'ACME.pkg'
options[:ipa] = nil
end
it 'uploads the PKG for the macOS platform' do
expect_any_instance_of(FastlaneCore::PkgUploadPackageBuilder).to receive(:generate)
.with(app_id: 'YI8C2AS', pkg_path: 'ACME.pkg', package_path: '/tmp', platform: 'osx')
.and_return('path')
expect(transporter).to receive(:upload).with(package_path: 'path', asset_path: 'ACME.pkg', platform: 'osx').and_return(true)
runner.upload_binary
end
end
end
describe :verify_binary do
let(:transporter) { MockTransporter.new }
before do
allow(FastlaneCore::ItunesTransporter).to receive(:new).and_return(transporter)
end
describe 'with an IPA file for iOS' do
it 'verifies the IPA for the iOS platform' do
expect_any_instance_of(FastlaneCore::IpaUploadPackageBuilder).to receive(:generate)
.with(app_id: 'YI8C2AS', ipa_path: 'ACME.ipa', package_path: '/tmp', platform: 'ios')
.and_return('path')
expect(transporter).to receive(:verify).with(package_path: 'path').and_return(true)
runner.verify_binary
end
end
describe 'with an IPA file for tvOS' do
before do
options[:platform] = 'appletvos'
end
it 'verifies the IPA for the tvOS platform' do
expect_any_instance_of(FastlaneCore::IpaUploadPackageBuilder).to receive(:generate)
.with(app_id: 'YI8C2AS', ipa_path: 'ACME.ipa', package_path: '/tmp', platform: 'appletvos')
.and_return('path')
expect(transporter).to receive(:verify).with(package_path: 'path').and_return(true)
runner.verify_binary
end
end
describe 'with a PKG file for macOS' do
before do
options[:platform] = 'osx'
options[:pkg] = 'ACME.pkg'
options[:ipa] = nil
end
it 'verifies the PKG for the macOS platform' do
expect_any_instance_of(FastlaneCore::PkgUploadPackageBuilder).to receive(:generate)
.with(app_id: 'YI8C2AS', pkg_path: 'ACME.pkg', package_path: '/tmp', platform: 'osx')
.and_return('path')
expect(transporter).to receive(:verify).with(package_path: 'path').and_return(true)
runner.verify_binary
end
end
end
end