-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add flag to conjurctl server to skip migrations #2895
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -42,6 +42,10 @@ | |
c.default_value(ENV['PORT'] || '80') | ||
c.flag [ :p, :port ] | ||
|
||
c.desc 'Skip running database migrations on start' | ||
c.default_value false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use parentheses for method calls with arguments. |
||
c.switch :'no-migrate' | ||
|
||
c.desc 'Server bind address' | ||
c.default_value(ENV['BIND_ADDRESS'] || '0.0.0.0') | ||
c.arg_name :ip | ||
|
@@ -55,7 +59,8 @@ | |
password_from_stdin: options["password-from-stdin"], | ||
file_name: options[:file], | ||
bind_address: options[:'bind-address'], | ||
port: options[:port] | ||
port: options[:port], | ||
no_migrate: options[:'no-migrate'] | ||
) | ||
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
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,76 @@ | ||
require 'spec_helper' | ||
|
||
require 'commands/server' | ||
|
||
describe Commands::Server do | ||
|
||
let(:account) { "demo" } | ||
let(:password_from_stdin) { false } | ||
let(:file_name) { nil } | ||
let(:bind_address) { "0.0.0.0" } | ||
let(:port) { 80 } | ||
let(:no_migrate) { false } | ||
|
||
let(:migrate_database) { | ||
double('DB::Migrate').tap do |migrate| | ||
allow(migrate).to receive(:call).with(preview: false) | ||
end | ||
} | ||
let(:connect_database) { | ||
double('ConnectDatabase').tap do |connect| | ||
allow(connect).to receive(:call) | ||
end | ||
} | ||
|
||
before do | ||
# Squash process forking for these tests as we have not implemented a full test | ||
# suite and it causes issues | ||
allow(Process).to receive(:fork).and_return(nil) | ||
allow(Process).to receive(:waitall).and_return(nil) | ||
end | ||
|
||
def delete_account(name) | ||
system("conjurctl account delete #{name}") | ||
end | ||
|
||
after(:each) do | ||
delete_account("demo") | ||
end | ||
|
||
|
||
subject do | ||
Commands::Server.new( | ||
migrate_database: migrate_database, | ||
connect_database: connect_database | ||
).call( | ||
account: account, | ||
password_from_stdin: password_from_stdin, | ||
file_name: file_name, | ||
bind_address: bind_address, | ||
port: port, | ||
no_migrate: no_migrate | ||
) | ||
end | ||
|
||
it "performs migrations" do | ||
expect(migrate_database).to receive(:call) | ||
|
||
subject | ||
end | ||
|
||
context "With the no_migrate variable set to true" do | ||
let(:no_migrate) { true } | ||
|
||
it "doesn't perform migrations" do | ||
expect(migrate_database).not_to receive(:call) | ||
|
||
subject | ||
end | ||
|
||
it "connects to the database" do | ||
expect(connect_database).to receive(:call) | ||
|
||
subject | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lists should be surrounded by blank lines