|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require "cases/helper" |
| 4 | + |
| 5 | +module ActiveRecord |
| 6 | + class DatabaseConfigurations |
| 7 | + class UrlConfigTest < ActiveRecord::TestCase |
| 8 | + def test_schema_dump_parsing |
| 9 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?schema_dump=false", {}) |
| 10 | + assert_nil config.schema_dump |
| 11 | + |
| 12 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?schema_dump=db/foo_schema.rb", {}) |
| 13 | + assert_equal "db/foo_schema.rb", config.schema_dump |
| 14 | + |
| 15 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo", {}) |
| 16 | + assert_equal "schema.rb", config.schema_dump |
| 17 | + end |
| 18 | + |
| 19 | + def test_query_cache_parsing |
| 20 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?query_cache=false", {}) |
| 21 | + assert_equal false, config.query_cache |
| 22 | + |
| 23 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?query_cache=42", {}) |
| 24 | + assert_equal "42", config.query_cache |
| 25 | + end |
| 26 | + |
| 27 | + def test_replica_parsing |
| 28 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo", {}) |
| 29 | + assert_nil config.replica? |
| 30 | + |
| 31 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?replica=true", {}) |
| 32 | + assert_equal true, config.replica? |
| 33 | + |
| 34 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?replica=false", {}) |
| 35 | + assert_equal false, config.replica? |
| 36 | + |
| 37 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?replica=random", {}) |
| 38 | + assert_equal true, config.replica? |
| 39 | + end |
| 40 | + |
| 41 | + def test_database_tasks_parsing |
| 42 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo", {}) |
| 43 | + assert_equal true, config.database_tasks? |
| 44 | + |
| 45 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?database_tasks=random", {}) |
| 46 | + assert_equal true, config.database_tasks? |
| 47 | + |
| 48 | + config = UrlConfig.new("default_env", "primary", "postgres://localhost/foo?database_tasks=false", {}) |
| 49 | + assert_equal false, config.database_tasks? |
| 50 | + end |
| 51 | + end |
| 52 | + end |
| 53 | +end |
0 commit comments