Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup: add skip_cleanup for dpl v1 #704

Merged
merged 2 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/travis/cli/setup/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def deploy(provider, verb = "deploy")
on("#{verb.capitalize} only from #{repository.slug}? ", config, 'repo' => repository.slug)
on("#{verb.capitalize} from #{branch} branch? ", config, 'branch' => branch) if branch != 'master' and branch != 'HEAD'

config['skip_cleanup'] = 'true' if not ( config.has_key?('skip_cleanup') or config.fetch('edge', 'false') != 'false' )

encrypt(config, 'password') if config['password'] and agree("Encrypt Password? ") { |q| q.default = 'yes' }
encrypt(config, 'api_key') if config['api_key'] and agree("Encrypt API key? ") { |q| q.default = 'yes' }
end
Expand Down
53 changes: 53 additions & 0 deletions spec/cli/setup/service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require 'spec_helper'

describe Travis::CLI::Setup::Service do
subject :service do
repository = double('repository',{:slug => 'test_slug'})
setup = double('Setup', :repository => repository)
described_class.new(setup)
end

describe '#deploy' do

subject :deploy_config do
{'provider' => 'dummy'}
end

before do
allow(service).to receive(:configure).and_yield(deploy_config)
allow(service).to receive(:on).and_return(nil)
end

context 'with no existing deploy section' do

it 'creates section contents without optional items' do
service.send(:deploy, 'dummy') { |_| }
expect(deploy_config).to include(
'provider' => 'dummy',
'skip_cleanup' => 'true'
)
end
end

context 'with existing deploy section' do
it 'doesn\'t overwrite existing skip_cleanup' do
deploy_config['skip_cleanup']='false'
service.send(:deploy, 'dummy') { |_| }
expect(deploy_config).to include('skip_cleanup' => 'false')
end

it 'doesn\'t set skip_cleanup for v2' do
deploy_config['edge']='true'
service.send(:deploy, 'dummy') { |_| }
expect(deploy_config).not_to include('skip_cleanup')
end

it 'sets skip_cleanup for explicit v1' do
deploy_config['edge']='false'
service.send(:deploy, 'dummy') { |_| }
expect(deploy_config).to include('skip_cleanup' => 'true')
end
end

end
end
2 changes: 1 addition & 1 deletion spec/client/auto_login_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
context "authenticate" do
context "when user has a token in cli config" do
it "does not call Tools::Github#with_token" do
expect(Travis::Tools::Github.any_instance).to_not receive(:with_token)
expect_any_instance_of(Travis::Tools::Github).to_not receive(:with_token)
auto_login_with_token.authenticate
end
end
Expand Down