This repository has been archived by the owner on May 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6623ae8
commit 3a229b5
Showing
9 changed files
with
144 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
## MacOS | ||
.DS_Store | ||
|
||
## Gems | ||
|
||
*.gem | ||
Gemfile.lock | ||
gems | ||
vendor | ||
.bundle | ||
|
||
## Documentation cache and generated files: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 15 additions & 23 deletions
38
lib/fastlane/plugin/fetch_version_code/actions/fetch_version_code_action.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 17 additions & 5 deletions
22
lib/fastlane/plugin/fetch_version_code/helper/fetch_version_code_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Fastlane | ||
module FetchVersionCode | ||
VERSION = "0.1.1" | ||
VERSION = "0.1.2" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,63 @@ | ||
describe Fastlane::Actions::FetchVersionCodeAction do | ||
describe '#run' do | ||
it 'prints a message' do | ||
expect(Fastlane::UI).to receive(:message).with("The fetch_version_code plugin is working!") | ||
it 'should run action' do | ||
allow(Fastlane::Helper::FetchVersionCodeHelper).to receive(:fetch_version_code).and_return('42') | ||
|
||
Fastlane::Actions::FetchVersionCodeAction.run(nil) | ||
expect(Fastlane::UI).to receive(:message).with('About to fetch a version code for: ios') | ||
expect(Fastlane::UI).to receive(:success).with('Got version code: 42') | ||
result = Fastlane::Actions::FetchVersionCodeAction.run(version_api_host: 'domain.tld', platform: 'ios', secret: 'foobarbaz') | ||
expect(result).to eq('42') | ||
end | ||
end | ||
|
||
describe '#description' do | ||
it 'should return description' do | ||
result = Fastlane::Actions::FetchVersionCodeAction.description | ||
expect(result).to eq('Fetch (and increment) version code for given platform') | ||
end | ||
end | ||
|
||
describe '#authors' do | ||
it 'should return authors' do | ||
result = Fastlane::Actions::FetchVersionCodeAction.authors | ||
expect(result).to eq(['AdrieanKhisbe', 'VincentCATILLON']) | ||
end | ||
end | ||
|
||
describe '#return_value' do | ||
it 'should return return_value' do | ||
result = Fastlane::Actions::FetchVersionCodeAction.return_value | ||
expect(result).to eq('Version code of given platform') | ||
end | ||
end | ||
|
||
describe '#available_options' do | ||
it 'should return available_options' do | ||
result = Fastlane::Actions::FetchVersionCodeAction.available_options | ||
expected = [ | ||
FastlaneCore::ConfigItem.new( | ||
key: :version_api_host, | ||
env_name: 'VERSION_API_HOST', | ||
description: 'API Token for FetchVersionCodeAction', | ||
is_string: true, | ||
default_value: 'api.coorpacademy.com' | ||
), | ||
FastlaneCore::ConfigItem.new(key: :platform, is_string: false, description: 'The platform to fetch version for'), | ||
FastlaneCore::ConfigItem.new(key: :secret, env_name: 'VERSION_API_SECRET') | ||
] | ||
expect(result.to_json).to eq(expected.to_json) | ||
end | ||
end | ||
|
||
describe '#is_supported' do | ||
it 'should return false' do | ||
result = Fastlane::Actions::FetchVersionCodeAction.is_supported?(:windows) | ||
expect(result).to be false | ||
end | ||
|
||
it 'should return true' do | ||
result = Fastlane::Actions::FetchVersionCodeAction.is_supported?(:ios) | ||
expect(result).to be true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
describe Fastlane::Helper::FetchVersionCodeHelper do | ||
describe '#get_api_url' do | ||
it 'should create URL' do | ||
result = Fastlane::Helper::FetchVersionCodeHelper.get_api_url(version_api_host: 'domain.tld', platform: 'ios') | ||
expect(result).to eq('https://domain.tld/build/api/v1/versions/ios/increment') | ||
end | ||
end | ||
|
||
describe '#fetch_version_code' do | ||
it 'should raise error' do | ||
allow(Fastlane::Helper::FetchVersionCodeHelper).to receive(:get_api_url).and_return('https://domain.tld') | ||
stub_request(:post, 'https://domain.tld') | ||
.with(headers: { api_secret: 'foobarbaz' }) | ||
.to_return(status: 404, body: '42') | ||
|
||
expect(Fastlane::UI).to receive(:message).with('Calling API: https://domain.tld') | ||
expect(Fastlane::UI).to receive(:error).with('Some error occureds [status:404 Not Found]: 42') | ||
expect { Fastlane::Helper::FetchVersionCodeHelper.fetch_version_code(version_api_host: 'domain.tld', platform: 'ios', secret: 'foobarbaz') }.to raise_error('42') | ||
end | ||
|
||
it 'should fetch version' do | ||
allow(Fastlane::Helper::FetchVersionCodeHelper).to receive(:get_api_url).and_return('https://domain.tld') | ||
stub_request(:post, 'https://domain.tld') | ||
.with(headers: { api_secret: 'foobarbaz' }) | ||
.to_return(status: 200, body: '42') | ||
|
||
expect(Fastlane::UI).to receive(:message).with('Calling API: https://domain.tld') | ||
result = Fastlane::Helper::FetchVersionCodeHelper.fetch_version_code(version_api_host: 'domain.tld', platform: 'ios', secret: 'foobarbaz') | ||
expect(result).to eq('42') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe Fastlane::FetchVersionCode do | ||
describe '#VERSION' do | ||
it 'should returns version' do | ||
expect(Fastlane::FetchVersionCode::VERSION).to eq('0.1.2') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters