Skip to content

Commit e4582c2

Browse files
chore: add test for _parse_connection_name_with_domain_name
1 parent da8fea2 commit e4582c2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/unit/test_connection_name.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import pytest # noqa F401 Needed to run the tests
1616

1717
from google.cloud.sql.connector.connection_name import _parse_connection_name
18+
from google.cloud.sql.connector.connection_name import (
19+
_parse_connection_name_with_domain_name,
20+
)
1821
from google.cloud.sql.connector.connection_name import ConnectionName
1922

2023

@@ -64,3 +67,32 @@ def test_parse_connection_name_bad_conn_name() -> None:
6467
"""
6568
with pytest.raises(ValueError):
6669
_parse_connection_name("project:instance") # missing region
70+
71+
72+
@pytest.mark.parametrize(
73+
"connection_name, domain_name, expected",
74+
[
75+
(
76+
"project:region:instance",
77+
"db.example.com",
78+
ConnectionName("project", "region", "instance", "db.example.com"),
79+
),
80+
(
81+
"domain-prefix:project:region:instance",
82+
"db.example.com",
83+
ConnectionName(
84+
"domain-prefix:project", "region", "instance", "db.example.com"
85+
),
86+
),
87+
],
88+
)
89+
def test_parse_connection_name_with_domain_name(
90+
connection_name: str, domain_name: str, expected: ConnectionName
91+
) -> None:
92+
"""
93+
Test that _parse_connection_name_with_domain_name works correctly on
94+
normal instance connection names and domain-scoped projects.
95+
"""
96+
assert expected == _parse_connection_name_with_domain_name(
97+
connection_name, domain_name
98+
)

0 commit comments

Comments
 (0)