Skip to content

Commit

Permalink
Merge pull request #1747 from mamhoff/allow-postgres-port
Browse files Browse the repository at this point in the history
Allow importing to a different port
  • Loading branch information
tvdeyen authored Mar 18, 2020
2 parents 07f7456 + b551d51 commit 2d5da13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/alchemy/tasks/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def postgres_command(cmd = 'psql')
if (host = database_config['host']) && (host != 'localhost')
command << "--host='#{host}'"
end
if (port = database_config['port'])
command << "--port=#{port}"
end
command.join(' ')
end

Expand Down
7 changes: 7 additions & 0 deletions spec/tasks/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ class Foo
it { is_expected.to include("PGPASSWORD='123456'") }
end

context "when a port is set in the config file" do
before do
allow(File).to receive(:read).and_return("test:\n port: 5433")
end
it { is_expected.to include("--port=5433") }
end

context "when a host is set in the config file" do
context "and the host is localhost" do
it { is_expected.not_to include("--host=") }
Expand Down

0 comments on commit 2d5da13

Please sign in to comment.