Skip to content

Commit

Permalink
#47 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 19, 2024
1 parent f322ba1 commit 68e21f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Metrics/ClassLength:
Metrics/MethodLength:
Max: 100
Metrics/PerceivedComplexity:
Max: 12
Max: 15
Metrics/ParameterLists:
Max: 6
5 changes: 4 additions & 1 deletion lib/pgtk/liquibase_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def run
https://docs.liquibase.com/concepts/changelogs/xml-format.html"
end
pom = File.expand_path(File.join(__dir__, '../../resources/pom.xml'))
old = @liquibase_version.match?(/^[1-3]\..+$/)
Dir.chdir(File.dirname(@master)) do
system(
[
Expand All @@ -87,7 +88,9 @@ def run
'--define',
"postgresql.version=#{@postgresql_version}",
'--define',
"liquibase.changeLogFile=#{@master}",
"liquibase.searchPath=#{File.dirname(@master)}",
'--define',
"liquibase.changeLogFile=#{old ? @master : File.basename(@master)}",
'--define',
"liquibase.url=#{Shellwords.escape(yml['pgsql']['url'])}",
'--define',
Expand Down
21 changes: 21 additions & 0 deletions test/test_liquibase_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ def test_basic
end
end

def test_latest_version
Dir.mktmpdir 'test' do |dir|
Pgtk::PgsqlTask.new(:pgsql) do |t|
t.dir = File.join(dir, 'pgsql')
t.user = 'xxx'
t.password = 'xxx'
t.dbname = 'xxx'
t.yaml = File.join(dir, 'xxx.yml')
t.quiet = true
end
Rake::Task['pgsql'].invoke
Pgtk::LiquibaseTask.new(:liquibase) do |t|
t.master = File.join(__dir__, '../test-resources/master.xml')
t.yaml = File.join(dir, 'xxx.yml')
t.postgresql_version = '42.7.1'
t.liquibase_version = '4.25.1'
end
Rake::Task['liquibase'].invoke
end
end

def test_with_invalid_master_file
Pgtk::LiquibaseTask.new(:lb) do |t|
t.master = 'the-file-doesnt-exist.xml'
Expand Down

0 comments on commit 68e21f3

Please sign in to comment.