|
136 | 136 | end.to raise_error("Unsupported distribution file format, should be .ipa, .apk or .aab")
|
137 | 137 | end
|
138 | 138 | end
|
| 139 | + |
| 140 | + describe '#xcode_archive_path' do |
| 141 | + it 'returns the archive path is set, and platform is not Android' do |
| 142 | + allow(Fastlane::Actions).to receive(:lane_context).and_return({ |
| 143 | + XCODEBUILD_ARCHIVE: '/path/to/archive' |
| 144 | + }) |
| 145 | + expect(helper.xcode_archive_path).to eq('/path/to/archive') |
| 146 | + end |
| 147 | + |
| 148 | + it 'returns nil if platform is Android' do |
| 149 | + allow(Fastlane::Actions).to receive(:lane_context).and_return({ |
| 150 | + XCODEBUILD_ARCHIVE: '/path/to/archive', |
| 151 | + PLATFORM_NAME: :android |
| 152 | + }) |
| 153 | + expect(helper.xcode_archive_path).to be_nil |
| 154 | + end |
| 155 | + |
| 156 | + it 'returns nil if the archive path is not set' do |
| 157 | + allow(Fastlane::Actions).to receive(:lane_context).and_return({}) |
| 158 | + expect(helper.xcode_archive_path).to be_nil |
| 159 | + end |
| 160 | + end |
| 161 | + |
| 162 | + describe '#app_id_from_params' do |
| 163 | + it 'returns the app id from the app parameter if set' do |
| 164 | + expect(helper).not_to(receive(:xcode_archive_path)) |
| 165 | + |
| 166 | + params = { app: 'app-id' } |
| 167 | + result = helper.app_id_from_params(params) |
| 168 | + |
| 169 | + expect(result).to eq('app-id') |
| 170 | + end |
| 171 | + |
| 172 | + it 'raises if the app parameter is not set and there is no archive path' do |
| 173 | + allow(helper).to receive(:xcode_archive_path).and_return(nil) |
| 174 | + |
| 175 | + params = {} |
| 176 | + expect { helper.app_id_from_params(params) } |
| 177 | + .to raise_error(ErrorMessage::MISSING_APP_ID) |
| 178 | + end |
| 179 | + |
| 180 | + it 'returns the app id from the plist if the archive path is set' do |
| 181 | + allow(helper).to receive(:xcode_archive_path).and_return('/path/to/archive') |
| 182 | + allow(helper).to receive(:get_ios_app_id_from_archive_plist) |
| 183 | + .with('/path/to/archive', '/path/to/plist') |
| 184 | + .and_return('app-id-from-plist') |
| 185 | + |
| 186 | + params = { googleservice_info_plist_path: '/path/to/plist' } |
| 187 | + result = helper.app_id_from_params(params) |
| 188 | + |
| 189 | + expect(result).to eq('app-id-from-plist') |
| 190 | + end |
| 191 | + |
| 192 | + it 'returns the app id from the plist if there is no archive path and it is found directly at the given path' do |
| 193 | + allow(helper).to receive(:xcode_archive_path).and_return(nil) |
| 194 | + allow(helper).to receive(:get_ios_app_id_from_plist) |
| 195 | + .with('/path/to/plist') |
| 196 | + .and_return('app-id-from-plist') |
| 197 | + |
| 198 | + params = { googleservice_info_plist_path: '/path/to/plist' } |
| 199 | + result = helper.app_id_from_params(params) |
| 200 | + |
| 201 | + expect(result).to eq('app-id-from-plist') |
| 202 | + end |
| 203 | + |
| 204 | + it 'raises if the app parameter is not set and the plist is empty' do |
| 205 | + allow(helper).to receive(:xcode_archive_path).and_return('/path/to/archive') |
| 206 | + allow(helper).to receive(:get_ios_app_id_from_archive_plist) |
| 207 | + .with('/path/to/archive', '/path/to/plist') |
| 208 | + .and_return(nil) |
| 209 | + |
| 210 | + params = { googleservice_info_plist_path: '/path/to/plist' } |
| 211 | + expect { helper.app_id_from_params(params) } |
| 212 | + .to raise_error(ErrorMessage::MISSING_APP_ID) |
| 213 | + end |
| 214 | + end |
139 | 215 | end
|
0 commit comments