pgtk 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.0pdd.yml +2 -19
- data/.github/workflows/actionlint.yml +4 -20
- data/.github/workflows/codecov.yml +10 -26
- data/.github/workflows/copyrights.yml +4 -19
- data/.github/workflows/license.yml +4 -19
- data/.github/workflows/markdown-lint.yml +4 -19
- data/.github/workflows/pdd.yml +5 -20
- data/.github/workflows/rake.yml +9 -24
- data/.github/workflows/reuse.yml +21 -0
- data/.github/workflows/xcop.yml +4 -19
- data/.github/workflows/yamllint.yml +4 -19
- data/.gitignore +2 -0
- data/.rubocop.yml +8 -20
- data/.rultor.yml +5 -21
- data/.simplecov +2 -19
- data/.yamllint.yml +2 -19
- data/Gemfile +10 -23
- data/Gemfile.lock +64 -34
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +11 -4
- data/REUSE.toml +17 -0
- data/Rakefile +8 -37
- data/cucumber.yml +2 -19
- data/lib/pgtk/liquibase_task.rb +3 -20
- data/lib/pgtk/pgsql_task.rb +3 -20
- data/lib/pgtk/pool.rb +36 -25
- data/lib/pgtk/spy.rb +36 -0
- data/lib/pgtk/version.rb +4 -21
- data/lib/pgtk/wire.rb +6 -23
- data/lib/pgtk.rb +3 -20
- data/pgtk.gemspec +2 -19
- data/resources/pom.xml +4 -23
- data/test/test__helper.rb +2 -19
- data/test/test_liquibase_task.rb +7 -22
- data/test/test_pgsql_task.rb +5 -22
- data/test/test_pool.rb +42 -34
- data/test-resources/2019/01-test.xml +2 -21
- data/test-resources/master.xml +2 -21
- metadata +6 -2
data/lib/pgtk/wire.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
require 'pg'
|
24
7
|
require 'uri'
|
@@ -27,14 +10,14 @@ require_relative '../pgtk'
|
|
27
10
|
|
28
11
|
# Wires.
|
29
12
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
13
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
31
14
|
# License:: MIT
|
32
15
|
module Pgtk::Wire
|
33
16
|
end
|
34
17
|
|
35
18
|
# Simple wire with details.
|
36
19
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
|
-
# Copyright:: Copyright (c) 2019-
|
20
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
38
21
|
# License:: MIT
|
39
22
|
class Pgtk::Wire::Direct
|
40
23
|
# Constructor.
|
@@ -59,7 +42,7 @@ end
|
|
59
42
|
|
60
43
|
# Using ENV variable.
|
61
44
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
62
|
-
# Copyright:: Copyright (c) 2019-
|
45
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
63
46
|
# License:: MIT
|
64
47
|
class Pgtk::Wire::Env
|
65
48
|
# Constructor.
|
@@ -85,7 +68,7 @@ end
|
|
85
68
|
|
86
69
|
# Using configuration from YAML file.
|
87
70
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
88
|
-
# Copyright:: Copyright (c) 2019-
|
71
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
89
72
|
# License:: MIT
|
90
73
|
class Pgtk::Wire::Yaml
|
91
74
|
# Constructor.
|
data/lib/pgtk.rb
CHANGED
@@ -1,28 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
# Pgtk main module.
|
24
7
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
25
|
-
# Copyright:: Copyright (c) 2019-
|
8
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
26
9
|
# License:: MIT
|
27
10
|
module Pgtk
|
28
11
|
# Nothing here.
|
data/pgtk.gemspec
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
require 'English'
|
24
7
|
|
data/resources/pom.xml
CHANGED
@@ -1,26 +1,7 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
2
|
<!--
|
3
|
-
(
|
4
|
-
|
5
|
-
Copyright (c) 2019-2024 Yegor Bugayenko
|
6
|
-
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
of this software and associated documentation files (the 'Software'), to deal
|
9
|
-
in the Software without restriction, including without limitation the rights
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
12
|
-
furnished to do so, subject to the following conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
15
|
-
copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
-
SOFTWARE.
|
3
|
+
* SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
* SPDX-License-Identifier: MIT
|
24
5
|
-->
|
25
6
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
26
7
|
<modelVersion>4.0.0</modelVersion>
|
@@ -29,8 +10,8 @@ SOFTWARE.
|
|
29
10
|
<version>0.0.0</version>
|
30
11
|
<packaging>pom</packaging>
|
31
12
|
<properties>
|
32
|
-
<postgresql.version>42.7.
|
33
|
-
<liquibase.version>4.
|
13
|
+
<postgresql.version>42.7.5</postgresql.version>
|
14
|
+
<liquibase.version>4.31.1</liquibase.version>
|
34
15
|
</properties>
|
35
16
|
<dependencies>
|
36
17
|
<dependency>
|
data/test/test__helper.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
$stdout.sync = true
|
24
7
|
|
data/test/test_liquibase_task.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
require 'minitest/autorun'
|
24
7
|
require 'tmpdir'
|
@@ -29,7 +12,7 @@ require_relative '../lib/pgtk/liquibase_task'
|
|
29
12
|
|
30
13
|
# Liquibase rake task test.
|
31
14
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
32
|
-
# Copyright:: Copyright (c) 2017-
|
15
|
+
# Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
|
33
16
|
# License:: MIT
|
34
17
|
class TestLiquibaseTask < Minitest::Test
|
35
18
|
def test_basic
|
@@ -70,6 +53,7 @@ class TestLiquibaseTask < Minitest::Test
|
|
70
53
|
t.yaml = File.join(dir, 'xxx.yml')
|
71
54
|
t.postgresql_version = '42.7.1'
|
72
55
|
t.liquibase_version = '4.25.1'
|
56
|
+
t.quiet = true
|
73
57
|
end
|
74
58
|
Rake::Task['liquibase'].invoke
|
75
59
|
end
|
@@ -79,10 +63,11 @@ class TestLiquibaseTask < Minitest::Test
|
|
79
63
|
Pgtk::LiquibaseTask.new(:lb) do |t|
|
80
64
|
t.master = 'the-file-doesnt-exist.xml'
|
81
65
|
t.yaml = { 'pgsql' => {} }
|
66
|
+
t.quiet = true
|
82
67
|
end
|
83
|
-
ex = assert_raises do
|
68
|
+
ex = assert_raises(StandardError) do
|
84
69
|
Rake::Task['lb'].invoke
|
85
70
|
end
|
86
|
-
|
71
|
+
assert_includes(ex.message, 'the-file-doesnt-exist.xml')
|
87
72
|
end
|
88
73
|
end
|
data/test/test_pgsql_task.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
require 'minitest/autorun'
|
24
7
|
require 'rake'
|
@@ -28,7 +11,7 @@ require_relative '../lib/pgtk/pgsql_task'
|
|
28
11
|
|
29
12
|
# Pgsql rake task test.
|
30
13
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2017-
|
14
|
+
# Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
|
32
15
|
# License:: MIT
|
33
16
|
class TestPgsqlTask < Minitest::Test
|
34
17
|
def test_basic
|
@@ -58,7 +41,7 @@ class TestPgsqlTask < Minitest::Test
|
|
58
41
|
t.password = 'the password'
|
59
42
|
t.dbname = 'test'
|
60
43
|
t.yaml = File.join(dir, 'cfg.yml')
|
61
|
-
t.quiet =
|
44
|
+
t.quiet = true
|
62
45
|
t.config = {
|
63
46
|
log_directory: dir,
|
64
47
|
logging_collector: 'on',
|
@@ -69,7 +52,7 @@ class TestPgsqlTask < Minitest::Test
|
|
69
52
|
Rake::Task['p3'].invoke
|
70
53
|
yaml = YAML.load_file(File.join(dir, 'cfg.yml'))
|
71
54
|
assert(yaml['pgsql']['url'].start_with?('jdbc:postgresql://localhost'))
|
72
|
-
|
55
|
+
assert_path_exists(File.join(dir, 'pgsql.log'))
|
73
56
|
end
|
74
57
|
end
|
75
58
|
end
|
data/test/test_pool.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
require 'loog'
|
24
7
|
require 'minitest/autorun'
|
@@ -30,17 +13,18 @@ require 'yaml'
|
|
30
13
|
require_relative '../lib/pgtk/liquibase_task'
|
31
14
|
require_relative '../lib/pgtk/pgsql_task'
|
32
15
|
require_relative '../lib/pgtk/pool'
|
16
|
+
require_relative '../lib/pgtk/spy'
|
33
17
|
|
34
18
|
# Pool test.
|
35
19
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
36
|
-
# Copyright:: Copyright (c) 2017-
|
20
|
+
# Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
|
37
21
|
# License:: MIT
|
38
22
|
class TestPool < Minitest::Test
|
39
23
|
def test_reads_version
|
40
24
|
bootstrap do |pool|
|
41
25
|
ver = pool.version
|
42
26
|
assert(ver.start_with?('1'))
|
43
|
-
|
27
|
+
refute_includes(ver, ' ')
|
44
28
|
end
|
45
29
|
end
|
46
30
|
|
@@ -50,7 +34,31 @@ class TestPool < Minitest::Test
|
|
50
34
|
'INSERT INTO book (title) VALUES ($1) RETURNING id',
|
51
35
|
['Elegant Objects']
|
52
36
|
)[0]['id'].to_i
|
53
|
-
|
37
|
+
assert_predicate(id, :positive?)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_with_spy
|
42
|
+
queries = []
|
43
|
+
bootstrap do |pool|
|
44
|
+
pool = Pgtk::Spy.new(pool) { |sql| queries.append(sql) }
|
45
|
+
pool.exec(
|
46
|
+
'INSERT INTO book (title) VALUES ($1)',
|
47
|
+
['Elegant Objects']
|
48
|
+
)
|
49
|
+
end
|
50
|
+
assert_equal(1, queries.size)
|
51
|
+
assert_equal('INSERT INTO book (title) VALUES ($1)', queries.first)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_complex_query
|
55
|
+
bootstrap do |pool|
|
56
|
+
pool.exec(
|
57
|
+
"
|
58
|
+
INSERT INTO book (title) VALUES ('one');
|
59
|
+
INSERT INTO book (title) VALUES ('two');
|
60
|
+
"
|
61
|
+
)
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
@@ -61,17 +69,17 @@ class TestPool < Minitest::Test
|
|
61
69
|
'INSERT INTO book (title) VALUES ($1)',
|
62
70
|
['Object Thinking']
|
63
71
|
)
|
64
|
-
|
72
|
+
assert_includes(log.to_s, 'INSERT INTO book (title) VALUES ($1)')
|
65
73
|
end
|
66
74
|
end
|
67
75
|
|
68
76
|
def test_logs_errors
|
69
77
|
log = Loog::Buffer.new
|
70
78
|
bootstrap(log: log) do |pool|
|
71
|
-
assert_raises
|
79
|
+
assert_raises(PG::UndefinedTable) do
|
72
80
|
pool.exec('INSERT INTO tableDoesNotExist (a) VALUES (42)')
|
73
81
|
end
|
74
|
-
|
82
|
+
assert_includes(log.to_s, 'INSERT INTO tableDoesNotExist')
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
@@ -87,23 +95,23 @@ class TestPool < Minitest::Test
|
|
87
95
|
['Object Thinking']
|
88
96
|
)[0]['id'].to_i
|
89
97
|
end
|
90
|
-
|
98
|
+
assert_predicate(id, :positive?)
|
91
99
|
end
|
92
100
|
end
|
93
101
|
|
94
102
|
def test_transaction_with_error
|
95
103
|
bootstrap do |pool|
|
96
104
|
pool.exec('DELETE FROM book')
|
97
|
-
|
98
|
-
assert_raises do
|
105
|
+
assert_empty(pool.exec('SELECT * FROM book'))
|
106
|
+
assert_raises(StandardError) do
|
99
107
|
pool.transaction do |t|
|
100
108
|
t.exec('INSERT INTO book (title) VALUES ($1)', ['hey'])
|
101
109
|
t.exec('INSERT INTO book (error_here) VALUES ($1)', ['hey'])
|
102
110
|
end
|
103
111
|
end
|
104
|
-
|
112
|
+
assert_empty(pool.exec('SELECT * FROM book'))
|
105
113
|
pool.exec('INSERT INTO book (title) VALUES ($1)', ['another'])
|
106
|
-
|
114
|
+
refute_empty(pool.exec('SELECT * FROM book'))
|
107
115
|
end
|
108
116
|
end
|
109
117
|
|
@@ -128,7 +136,7 @@ class TestPool < Minitest::Test
|
|
128
136
|
t.password = 'A B C привет ! & | !'
|
129
137
|
t.dbname = 'test'
|
130
138
|
t.yaml = File.join(dir, 'cfg.yml')
|
131
|
-
t.quiet =
|
139
|
+
t.quiet = true
|
132
140
|
t.fresh_start = true
|
133
141
|
t.port = port
|
134
142
|
end
|
@@ -136,11 +144,11 @@ class TestPool < Minitest::Test
|
|
136
144
|
task.invoke
|
137
145
|
pool = Pgtk::Pool.new(
|
138
146
|
Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')),
|
139
|
-
log: Loog::
|
147
|
+
log: Loog::NULL
|
140
148
|
)
|
141
149
|
pool.start(1)
|
142
150
|
pool.exec('SELECT * FROM pg_catalog.pg_tables')
|
143
|
-
qbash("pg_ctl -D #{Shellwords.escape(File.join(dir, 'pgsql'))} stop", log:
|
151
|
+
qbash("pg_ctl -D #{Shellwords.escape(File.join(dir, 'pgsql'))} stop", log: nil)
|
144
152
|
cycle = 0
|
145
153
|
loop do
|
146
154
|
begin
|
@@ -176,7 +184,7 @@ class TestPool < Minitest::Test
|
|
176
184
|
|
177
185
|
private
|
178
186
|
|
179
|
-
def bootstrap(log: Loog::
|
187
|
+
def bootstrap(log: Loog::NULL)
|
180
188
|
Dir.mktmpdir 'test' do |dir|
|
181
189
|
id = rand(100..999)
|
182
190
|
Pgtk::PgsqlTask.new("pgsql#{id}") do |t|
|
@@ -1,26 +1,7 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
2
|
<!--
|
3
|
-
(
|
4
|
-
|
5
|
-
Copyright (c) 2019-2024 Yegor Bugayenko
|
6
|
-
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
of this software and associated documentation files (the 'Software'), to deal
|
9
|
-
in the Software without restriction, including without limitation the rights
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
12
|
-
furnished to do so, subject to the following conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
15
|
-
copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
-
SOFTWARE.
|
3
|
+
* SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
* SPDX-License-Identifier: MIT
|
24
5
|
-->
|
25
6
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd" logicalFilePath="001-initial-schema.xml">
|
26
7
|
<changeSet id="01" author="yegor256">
|
data/test-resources/master.xml
CHANGED
@@ -1,26 +1,7 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
2
|
<!--
|
3
|
-
(
|
4
|
-
|
5
|
-
Copyright (c) 2019-2024 Yegor Bugayenko
|
6
|
-
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
of this software and associated documentation files (the 'Software'), to deal
|
9
|
-
in the Software without restriction, including without limitation the rights
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
12
|
-
furnished to do so, subject to the following conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
15
|
-
copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
-
SOFTWARE.
|
3
|
+
* SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
|
4
|
+
* SPDX-License-Identifier: MIT
|
24
5
|
-->
|
25
6
|
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
|
26
7
|
<includeAll path="2019"/>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- ".github/workflows/markdown-lint.yml"
|
100
100
|
- ".github/workflows/pdd.yml"
|
101
101
|
- ".github/workflows/rake.yml"
|
102
|
+
- ".github/workflows/reuse.yml"
|
102
103
|
- ".github/workflows/xcop.yml"
|
103
104
|
- ".github/workflows/yamllint.yml"
|
104
105
|
- ".gitignore"
|
@@ -110,13 +111,16 @@ files:
|
|
110
111
|
- Gemfile
|
111
112
|
- Gemfile.lock
|
112
113
|
- LICENSE.txt
|
114
|
+
- LICENSES/MIT.txt
|
113
115
|
- README.md
|
116
|
+
- REUSE.toml
|
114
117
|
- Rakefile
|
115
118
|
- cucumber.yml
|
116
119
|
- lib/pgtk.rb
|
117
120
|
- lib/pgtk/liquibase_task.rb
|
118
121
|
- lib/pgtk/pgsql_task.rb
|
119
122
|
- lib/pgtk/pool.rb
|
123
|
+
- lib/pgtk/spy.rb
|
120
124
|
- lib/pgtk/version.rb
|
121
125
|
- lib/pgtk/wire.rb
|
122
126
|
- pgtk.gemspec
|