summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid E. Wheeler <david@justatheory.com>2023-05-10 19:13:39 -0400
committergregor herrmann <gregoa@debian.org>2023-06-18 19:25:25 +0200
commitfda6635c00dd3444ed08cee6e4c889a49b3140e5 (patch)
treeda97b1fbbcb992929ba54a00a604a2378106a105
parent10e1b5e2cfc1d3db5eeeb8467cbec67e5bc8558d (diff)
[PATCH] Use regexes to test database URIs & DSNs
When there is a username but no password, URI used to leave an orphan colon in the URI (reported in libwww-perl/URI#13). That bug was fixed in libwww-perl/URI#31, leading to failures in Sqitch tests expecting the colon to be present. libwww-perl/URI-db#23 also changed the DSN of URI::Oracle to specify the database name with `service_name=`. So change the tests to use regular expressions to match such URIs and DSNs, so that the presence of the colon or service name is optional. Resolves #744. Gbp-Pq: Name use_regexes_to_test_database_uris_and_dsns.patch
-rw-r--r--t/mysql.t6
-rw-r--r--t/oracle.t4
-rw-r--r--t/snowflake.t4
-rw-r--r--t/sqlite.t2
4 files changed, 8 insertions, 8 deletions
diff --git a/t/mysql.t b/t/mysql.t
index bf34c720..33ce8aed 100644
--- a/t/mysql.t
+++ b/t/mysql.t
@@ -135,14 +135,14 @@ ok $mysql = $CLASS->new(sqitch => $sqitch, target => $target),
is $mysql->client, '/path/to/mysql', 'client should be as configured';
is $mysql->uri->as_string, 'db:mysql://me:pwd@foo.com/widgets',
'URI should be as configured';
-is $mysql->target->name, 'db:mysql://me:@foo.com/widgets',
+like $mysql->target->name, qr{^db:mysql://me:?\@foo\.com/widgets$},
'target name should be the URI without the password';
-is $mysql->destination, 'db:mysql://me:@foo.com/widgets',
+like $mysql->destination, qr{^db:mysql://me:?\@foo\.com/widgets$},
'destination should be the URI without the password';
is $mysql->registry, 'meta', 'registry should be as configured';
is $mysql->registry_uri->as_string, 'db:mysql://me:pwd@foo.com/meta',
'Sqitch DB URI should be the same as uri but with DB name "meta"';
-is $mysql->registry_destination, 'db:mysql://me:@foo.com/meta',
+like $mysql->registry_destination, qr{^db:mysql://me:?\@foo\.com/meta$},
'registry_destination should be the sqitch DB URL without the password';
is_deeply [$mysql->mysql], [
'/path/to/mysql',
diff --git a/t/oracle.t b/t/oracle.t
index a5aabd22..4c81a1f5 100644
--- a/t/oracle.t
+++ b/t/oracle.t
@@ -243,7 +243,7 @@ $target = App::Sqitch::Target->new(
sqitch => $sqitch,
uri => URI::db->new('db:oracle:secure_user_tns.tpg'),
);
-is $target->uri->dbi_dsn, 'dbi:Oracle:secure_user_tns.tpg',
+like $target->uri->dbi_dsn, qr{^dbi:Oracle:(?:service_name=)?secure_user_tns\.tpg$},
'Database-only URI should produce proper DSN';
isa_ok $ora = $CLASS->new(
sqitch => $sqitch,
@@ -263,7 +263,7 @@ $target = App::Sqitch::Target->new(
sqitch => $sqitch,
uri => URI::db->new('db:oracle://:@/wallet_tns_name'),
);
-is $target->uri->dbi_dsn, 'dbi:Oracle:wallet_tns_name',
+like $target->uri->dbi_dsn, qr{dbi:Oracle:(?:service_name=)?wallet_tns_name$},
'Database and double-slash URI should produce proper DSN';
isa_ok $ora = $CLASS->new(
sqitch => $sqitch,
diff --git a/t/snowflake.t b/t/snowflake.t
index bec9e42e..3dc34e2c 100644
--- a/t/snowflake.t
+++ b/t/snowflake.t
@@ -322,8 +322,8 @@ is $snow->registry, 'meta', 'registry should be as configured';
is $snow->uri->as_string,
'db:snowflake://fred:hi@foo.snowflakecomputing.com/try?warehouse=foo;role=yup',
'URI should be as configured with full domain name';
-is $snow->destination,
- 'db:snowflake://fred:@foo.snowflakecomputing.com/try?warehouse=foo;role=yup',
+like $snow->destination,
+ qr{^db:snowflake://fred:?\@foo\.snowflakecomputing\.com/try\?warehouse=foo;role=yup$},
'Destination should omit password';
is $snow->client, '/path/to/snowsql', 'client should be as configured';
diff --git a/t/sqlite.t b/t/sqlite.t
index ce18fc45..42307390 100644
--- a/t/sqlite.t
+++ b/t/sqlite.t
@@ -157,7 +157,7 @@ is $sqlite->destination, 'noext',
'Destination should be configured target name';
is $sqlite->registry_uri->as_string, 'db:sqlite://x:foo@/path/to/registry.db',
'registry_uri should fall back on config wth extension';
-is $sqlite->registry_destination, 'db:sqlite://x:@/path/to/registry.db',
+like $sqlite->registry_destination, qr{^db:sqlite://x:?\@/path/to/registry\.db$},
'Registry target should be configured registry_uri without password';
# Try a registry with an absolute path.