pgtk 0.12.1 → 0.13.1
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 -24
- 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 +1 -1
- data/.rubocop.yml +8 -20
- data/.rultor.yml +5 -21
- data/.simplecov +2 -19
- data/.yamllint.yml +2 -19
- data/Gemfile +9 -23
- data/Gemfile.lock +62 -34
- data/LICENSES/MIT.txt +21 -0
- data/README.md +11 -4
- data/REUSE.toml +17 -0
- data/Rakefile +3 -29
- data/cucumber.yml +2 -19
- data/lib/pgtk/liquibase_task.rb +2 -19
- data/lib/pgtk/pgsql_task.rb +2 -19
- data/lib/pgtk/pool.rb +2 -19
- data/lib/pgtk/spy.rb +37 -0
- data/lib/pgtk/version.rb +3 -20
- data/lib/pgtk/wire.rb +2 -19
- data/lib/pgtk.rb +2 -19
- data/pgtk.gemspec +2 -19
- data/resources/pom.xml +4 -23
- data/test/test__helper.rb +2 -19
- data/test/test_liquibase_task.rb +5 -22
- data/test/test_pgsql_task.rb +4 -21
- data/test/test_pool.rb +28 -31
- data/test-resources/2019/01-test.xml +2 -21
- data/test-resources/master.xml +2 -21
- metadata +6 -2
data/test/test_liquibase_task.rb
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2019-2025 Yegor Bugayenko
|
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
|
@@ -82,9 +65,9 @@ class TestLiquibaseTask < Minitest::Test
|
|
82
65
|
t.yaml = { 'pgsql' => {} }
|
83
66
|
t.quiet = true
|
84
67
|
end
|
85
|
-
ex = assert_raises do
|
68
|
+
ex = assert_raises(StandardError) do
|
86
69
|
Rake::Task['lb'].invoke
|
87
70
|
end
|
88
|
-
|
71
|
+
assert_includes(ex.message, 'the-file-doesnt-exist.xml')
|
89
72
|
end
|
90
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-2025 Yegor Bugayenko
|
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
|
@@ -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-2025 Yegor Bugayenko
|
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,10 +34,23 @@ 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?)
|
54
38
|
end
|
55
39
|
end
|
56
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
|
+
|
57
54
|
def test_complex_query
|
58
55
|
bootstrap do |pool|
|
59
56
|
pool.exec(
|
@@ -72,23 +69,23 @@ class TestPool < Minitest::Test
|
|
72
69
|
'INSERT INTO book (title) VALUES ($1)',
|
73
70
|
['Object Thinking']
|
74
71
|
)
|
75
|
-
|
72
|
+
assert_includes(log.to_s, 'INSERT INTO book (title) VALUES ($1)')
|
76
73
|
end
|
77
74
|
end
|
78
75
|
|
79
76
|
def test_logs_errors
|
80
77
|
log = Loog::Buffer.new
|
81
78
|
bootstrap(log: log) do |pool|
|
82
|
-
assert_raises
|
79
|
+
assert_raises(PG::UndefinedTable) do
|
83
80
|
pool.exec('INSERT INTO tableDoesNotExist (a) VALUES (42)')
|
84
81
|
end
|
85
|
-
|
82
|
+
assert_includes(log.to_s, 'INSERT INTO tableDoesNotExist')
|
86
83
|
end
|
87
84
|
end
|
88
85
|
|
89
86
|
def test_transaction
|
90
87
|
bootstrap do |pool|
|
91
|
-
id = pool.transaction do |t|
|
88
|
+
id = Pgtk::Spy.new(pool).transaction do |t|
|
92
89
|
t.exec('DELETE FROM book')
|
93
90
|
t.exec(
|
94
91
|
[
|
@@ -98,23 +95,23 @@ class TestPool < Minitest::Test
|
|
98
95
|
['Object Thinking']
|
99
96
|
)[0]['id'].to_i
|
100
97
|
end
|
101
|
-
|
98
|
+
assert_predicate(id, :positive?)
|
102
99
|
end
|
103
100
|
end
|
104
101
|
|
105
102
|
def test_transaction_with_error
|
106
103
|
bootstrap do |pool|
|
107
104
|
pool.exec('DELETE FROM book')
|
108
|
-
|
109
|
-
assert_raises do
|
105
|
+
assert_empty(pool.exec('SELECT * FROM book'))
|
106
|
+
assert_raises(StandardError) do
|
110
107
|
pool.transaction do |t|
|
111
108
|
t.exec('INSERT INTO book (title) VALUES ($1)', ['hey'])
|
112
109
|
t.exec('INSERT INTO book (error_here) VALUES ($1)', ['hey'])
|
113
110
|
end
|
114
111
|
end
|
115
|
-
|
112
|
+
assert_empty(pool.exec('SELECT * FROM book'))
|
116
113
|
pool.exec('INSERT INTO book (title) VALUES ($1)', ['another'])
|
117
|
-
|
114
|
+
refute_empty(pool.exec('SELECT * FROM book'))
|
118
115
|
end
|
119
116
|
end
|
120
117
|
|
@@ -1,26 +1,7 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
2
|
<!--
|
3
|
-
(
|
4
|
-
|
5
|
-
Copyright (c) 2019-2025 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-2025 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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
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
|