Skip to content
Open
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
3 changes: 2 additions & 1 deletion clickhouse/lib/testcontainers/clickhouse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ClickhouseContainer < ::Testcontainers::DockerContainer
# @param kwargs [Hash] the options to pass to the container. See {DockerContainer#initialize}
# @return [ClickhouseContainer] a new instance of ClickhouseContainer
def initialize(image = CLICKHOUSE_DEFAULT_IMAGE, username: nil, password: nil, database: nil, **kwargs)
super(image, wait_for: WAIT_FOR_PROC, exposed_ports: [CLICKHOUSE_DEFAULT_PORT, CLICKHOUSE_DEFAULT_HTTP_PORT], **kwargs)
super(image, wait_for: WAIT_FOR_PROC, **kwargs)
@username = username || ENV.fetch("CLICKHOUSE_USER", CLICKHOUSE_DEFAULT_USER)
@password = password || ENV.fetch("CLICKHOUSE_PASSWORD", CLICKHOUSE_DEFAULT_PASS)
@database = database || ENV.fetch("CLICKHOUSE_DB", CLICKHOUSE_DB)
Expand All @@ -48,6 +48,7 @@ def initialize(image = CLICKHOUSE_DEFAULT_IMAGE, username: nil, password: nil, d
#
# @return [ClickhouseContainer] self
def start
with_exposed_ports(port, http_port)
_configure
super
end
Expand Down
12 changes: 12 additions & 0 deletions clickhouse/test/clickhouse_container_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ def test_it_has_the_default_ports_mapped
assert @container.mapped_port(9000)
end

def test_it_keeps_default_ports_when_custom_exposed_ports_are_given
container = Testcontainers::ClickhouseContainer.new(exposed_ports: [8443])
container.start

assert container.mapped_port(8443)
assert container.mapped_port(container.port)
assert container.mapped_port(container.http_port)
ensure
container&.stop if container&.running?
container&.remove if container&.exists?
end

def test_it_returns_the_default_clickhouse_url
assert_equal "clickhouse://default:password@#{@host}:#{@port}/default", @container.clickhouse_url
end
Expand Down
Loading