File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
hermetic_build/library_generation Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515import copy
16- import re
1716import shutil
1817from pathlib import Path
1918from typing import Optional
@@ -137,6 +136,8 @@ def _get_target_libraries_from_api_path(
137136 A list of LibraryConfig objects matching the target API path, or an
138137 empty list if no matches are found.
139138 """
139+ if not ends_with_version (target_api_path ):
140+ raise ValueError ("api_path is not ending with a version is not supported" )
140141 target_libraries = []
141142 for library in config .libraries :
142143 target_library = copy .deepcopy (library )
Original file line number Diff line number Diff line change @@ -114,6 +114,21 @@ def test_get_target_library_returns_selected_api_path_plus_dep(self):
114114
115115 self .assertEqual ([another_library_v1 ], target_libraries )
116116
117+ def test_get_target_library_invalid_target_api_path (self ):
118+ """
119+ Tests when the api_path is invalid and sys.exit is called.
120+ """
121+ config = GenerateRepoTest .__get_an_empty_library_config ()
122+ with self .assertRaises (ValueError ) as context :
123+ _target_libraries = get_target_libraries (
124+ config , target_api_path = "google/cloud/another/library/type"
125+ )
126+
127+ self .assertEqual (
128+ str (context .exception ),
129+ "api_path is not ending with a version is not supported" ,
130+ )
131+
117132 @staticmethod
118133 def __get_an_empty_generation_config () -> GenerationConfig :
119134 return GenerationConfig (
You can’t perform that action at this time.
0 commit comments