4545import rich_click as click
4646
4747# from airbyte_cdk.test.standard_tests import pytest_hooks
48+ from airbyte_cdk .cli .airbyte_cdk ._util import resolve_connector_name_and_directory
4849from airbyte_cdk .test .standard_tests .test_resources import find_connector_root_from_name
4950from airbyte_cdk .test .standard_tests .util import create_connector_test_suite
5051
@@ -97,12 +98,12 @@ def connector_cli_group() -> None:
9798@click .option (
9899 "--connector-name" ,
99100 type = str ,
100- # help="Name of the connector to test. Ignored if --connector-directory is provided.",
101+ help = "Name of the connector to test. Ignored if --connector-directory is provided." ,
101102)
102103@click .option (
103104 "--connector-directory" ,
104105 type = click .Path (exists = True , file_okay = False , path_type = Path ),
105- # help="Path to the connector directory.",
106+ help = "Path to the connector directory." ,
106107)
107108@click .option (
108109 "--collect-only" ,
@@ -129,23 +130,10 @@ def test(
129130 "pytest is not installed. Please install pytest to run the connector tests."
130131 )
131132 click .echo ("Connector test command executed." )
132- if not connector_name and not connector_directory :
133- cwd = Path ().resolve ().absolute ()
134- if cwd .name .startswith ("source-" ) or cwd .name .startswith ("destination-" ):
135- connector_name = cwd .name
136- connector_directory = cwd
137- else :
138- raise ValueError (
139- "Either connector_name or connector_directory must be provided if not "
140- "running from a connector directory."
141- )
142-
143- if connector_directory :
144- connector_directory = connector_directory .resolve ().absolute ()
145- elif connector_name :
146- connector_directory = find_connector_root_from_name (connector_name )
147- else :
148- raise ValueError ("Either connector_name or connector_directory must be provided." )
133+ connector_name , connector_directory = resolve_connector_name_and_directory (
134+ connector_name = connector_name ,
135+ connector_directory = connector_directory ,
136+ )
149137
150138 connector_test_suite = create_connector_test_suite (
151139 connector_name = connector_name if not connector_directory else None ,
0 commit comments