testcontainers-postgres 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +4 -3
- data/README.md +3 -3
- data/lib/testcontainers/postgres/version.rb +1 -1
- data/lib/testcontainers/postgres.rb +15 -4
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e17b7bd5c9abe596cdc1a6e2ed610ae649a06d4e1424fe80aa3b9da1583bd2f0
|
4
|
+
data.tar.gz: 971f6231a528fcf8a71d1ae12f34ab6a9643ae7dfc25e1368a9e0554481e714a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2419b01a2d5a0e2d3b1ee05e5de1e16b6fec111e7babb649d55a977cf76f2dc1082c774359481b2946ad8c01e0c6904e8f92bd6bc8442f8f3c68825d4fa0bd0
|
7
|
+
data.tar.gz: 349bcea207693f17f1024ecf98461faf8664d2c91cf7c5d5437abecf04b123903a218b83214e9a0cea6a57a0efae133c4c2337c08595742429d4834b14047fd0
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../core
|
3
3
|
specs:
|
4
|
-
testcontainers-core (0.
|
4
|
+
testcontainers-core (0.2.0)
|
5
5
|
docker-api (~> 2.2)
|
6
6
|
|
7
7
|
PATH
|
8
8
|
remote: .
|
9
9
|
specs:
|
10
|
-
testcontainers-postgres (0.
|
11
|
-
testcontainers-core (~> 0.1
|
10
|
+
testcontainers-postgres (0.2.0)
|
11
|
+
testcontainers-core (~> 0.1)
|
12
12
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
@@ -64,6 +64,7 @@ GEM
|
|
64
64
|
|
65
65
|
PLATFORMS
|
66
66
|
arm64-darwin-21
|
67
|
+
ruby
|
67
68
|
x86_64-darwin-22
|
68
69
|
|
69
70
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -119,7 +119,7 @@ You can manage the container in the `before(:suite)` / `after(:suite)` blocks in
|
|
119
119
|
|
120
120
|
```ruby
|
121
121
|
RSpec.configure do |config|
|
122
|
-
# This helps us to have access to the `RSpec.configuration.
|
122
|
+
# This helps us to have access to the `RSpec.configuration.postgres_container` without using global variables.
|
123
123
|
config.add_setting :postgres_container, default: nil
|
124
124
|
|
125
125
|
config.before(:suite) do
|
@@ -137,7 +137,7 @@ end
|
|
137
137
|
|
138
138
|
## Contributing
|
139
139
|
|
140
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
140
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/testcontainers/testcontainers-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/testcontainers/testcontainers-ruby/blob/main/CODE_OF_CONDUCT.md).
|
141
141
|
|
142
142
|
## License
|
143
143
|
|
@@ -145,4 +145,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
145
145
|
|
146
146
|
## Code of Conduct
|
147
147
|
|
148
|
-
Everyone interacting in the Testcontainers project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
148
|
+
Everyone interacting in the Testcontainers project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/testcontainers/testcontainers-ruby/blob/main/CODE_OF_CONDUCT.md).
|
@@ -5,7 +5,6 @@ require "uri"
|
|
5
5
|
module Testcontainers
|
6
6
|
# PostgresContainer class is used to manage containers that runs a PostgresQL database
|
7
7
|
#
|
8
|
-
# @attr_reader [String] port used by the container
|
9
8
|
# @attr_reader [String] username used by the container
|
10
9
|
# @attr_reader [String] password used by the container
|
11
10
|
# @attr_reader [String] database used by the container
|
@@ -20,7 +19,7 @@ module Testcontainers
|
|
20
19
|
POSTGRES_DEFAULT_PASSWORD = "test"
|
21
20
|
POSTGRES_DEFAULT_DATABASE = "test"
|
22
21
|
|
23
|
-
attr_reader :
|
22
|
+
attr_reader :username, :password, :database
|
24
23
|
|
25
24
|
# Initializes a new instance of PostgresContainer
|
26
25
|
#
|
@@ -33,21 +32,29 @@ module Testcontainers
|
|
33
32
|
# @return [PostgresContainer] a new instance of PostgresContainer
|
34
33
|
def initialize(image = POSTGRES_DEFAULT_IMAGE, username: nil, password: nil, database: nil, port: nil, **kwargs)
|
35
34
|
super(image, **kwargs)
|
36
|
-
@port = port || ENV.fetch("POSTGRES_PORT", POSTGRES_DEFAULT_PORT)
|
37
35
|
@username = username || ENV.fetch("POSTGRES_USER", POSTGRES_DEFAULT_USERNAME)
|
38
36
|
@password = password || ENV.fetch("POSTGRES_PASSWORD", POSTGRES_DEFAULT_PASSWORD)
|
39
37
|
@database = database || ENV.fetch("POSTGRES_DATABASE", POSTGRES_DEFAULT_DATABASE)
|
38
|
+
@healthcheck ||= add_healthcheck(_default_healthcheck_options)
|
39
|
+
@wait_for ||= add_wait_for(:healthcheck)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Starts the container
|
43
43
|
#
|
44
44
|
# @return [PostgresContainer] self
|
45
45
|
def start
|
46
|
-
with_exposed_ports(
|
46
|
+
with_exposed_ports(port)
|
47
47
|
_configure
|
48
48
|
super
|
49
49
|
end
|
50
50
|
|
51
|
+
# Returns the port used by the container
|
52
|
+
#
|
53
|
+
# @return [Integer] the port used by the container
|
54
|
+
def port
|
55
|
+
POSTGRES_DEFAULT_PORT
|
56
|
+
end
|
57
|
+
|
51
58
|
# Returns the database url (e.g. postgres://user:password@host:port/database)
|
52
59
|
#
|
53
60
|
# @param protocol [String] the protocol to use in the string (default: "postgres")
|
@@ -103,5 +110,9 @@ module Testcontainers
|
|
103
110
|
add_env("POSTGRES_PASSWORD", @password)
|
104
111
|
add_env("POSTGRES_ROOT_PASSWORD", @password)
|
105
112
|
end
|
113
|
+
|
114
|
+
def _default_healthcheck_options
|
115
|
+
{test: ["psql", "--port=#{port}", "--user=#{username}", "--dbname=#{database}", "--quiet", "-c", "\\l"], interval: 1, timeout: 5, retries: 5}
|
116
|
+
end
|
106
117
|
end
|
107
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testcontainers-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Piza
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: testcontainers-core
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.1
|
20
|
+
version: '0.1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.1
|
27
|
+
version: '0.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,13 +112,13 @@ files:
|
|
112
112
|
- Rakefile
|
113
113
|
- lib/testcontainers/postgres.rb
|
114
114
|
- lib/testcontainers/postgres/version.rb
|
115
|
-
homepage: https://github.com/
|
115
|
+
homepage: https://github.com/testcontainers/testcontainers-ruby
|
116
116
|
licenses:
|
117
117
|
- MIT
|
118
118
|
metadata:
|
119
|
-
homepage_uri: https://github.com/
|
120
|
-
source_code_uri: https://github.com/
|
121
|
-
changelog_uri: https://github.com/
|
119
|
+
homepage_uri: https://github.com/testcontainers/testcontainers-ruby/blob/main/postgres
|
120
|
+
source_code_uri: https://github.com/testcontainers/testcontainers-ruby/blob/main/postgres
|
121
|
+
changelog_uri: https://github.com/testcontainers/testcontainers-ruby/blob/main/postgres/CHANGELOG.md
|
122
122
|
post_install_message:
|
123
123
|
rdoc_options: []
|
124
124
|
require_paths:
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.4.
|
137
|
+
rubygems_version: 3.4.14
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: 'Testcontainers for Ruby: Postgres module'
|