Skip to content

Commit

Permalink
Merge pull request #44069 from ghiculescu/postgres-test-dump
Browse files Browse the repository at this point in the history
Actually run a `pg_dump` in the Postgres test suite
  • Loading branch information
rafaelfranca committed Jan 4, 2022
2 parents c83dbb9 + 16ed32e commit faf9beb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions activerecord/test/cases/tasks/postgresql_rake_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,17 @@ def teardown
FileUtils.rm_f(@filename)
end

# This test actually runs a dump so we can ensure all the arguments are parsed correctly.
# All other tests in this class just mock the call (using assert_called_with) to make the tests quicker.
def test_structure_dump
assert_called_with(
Kernel,
:system,
[{}, "pg_dump", "--schema-only", "--no-privileges", "--no-owner", "--no-comments", "--file", @filename, "my-app-db"],
returns: true
) do
ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, @filename)
end
assert_equal "", File.read(@filename)

config = @configuration.dup
config["database"] = ARTest.config["connections"]["postgresql"]["arunit"]["database"]

ActiveRecord::Tasks::DatabaseTasks.structure_dump(config, @filename)

assert File.read(@filename).include?("PostgreSQL database dump complete")
end

def test_structure_dump_header_comments_removed
Expand Down

0 comments on commit faf9beb

Please sign in to comment.