File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 99from .exceptions import ServiceFileNotFound , ServiceNotFound
1010
1111
12- def conf_path (create_if_missing : bool = False ) -> Path :
12+ def conf_path (create_if_missing : Optional [ bool ] = False ) -> Path :
1313 """Returns the path found for the pg_service.conf on the system as string.
1414
1515 Args:
Original file line number Diff line number Diff line change @@ -123,6 +123,25 @@ def test_remove_service(self):
123123 self .assertIn ("service_tmp" , service_names ())
124124 remove_service ("service_tmp" )
125125
126+ def test_missing_file (self ):
127+ another_service_file_path = PGSERVICEPARSER_SRC_PATH / "test" / "data" / "new_folder" / "pgservice.conf"
128+ os .environ ["PGSERVICEFILE" ] = str (another_service_file_path )
129+
130+ self .assertEqual (another_service_file_path , conf_path ())
131+ self .assertFalse (another_service_file_path .exists ())
132+ self .assertFalse (another_service_file_path .parent .exists ())
133+
134+ self .assertEqual (another_service_file_path , conf_path (create_if_missing = True ))
135+ self .assertTrue (another_service_file_path .exists ())
136+ self .assertTrue (another_service_file_path .parent .exists ())
137+
138+ os .environ ["PGSERVICEFILE" ] = str (self .service_file_path )
139+
140+ def tearDown (self ):
141+ new_folder_path = self .service_file_path .parent / "new_folder"
142+ if new_folder_path .exists ():
143+ shutil .rmtree (new_folder_path )
144+
126145
127146if __name__ == "__main__" :
128147 unittest .main ()
You can’t perform that action at this time.
0 commit comments