3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 from tools.releasereader import ReleaseReader
19 from tools.executor import Result
22 @pytest.mark.parametrize('curr_release, next_release', [
23 ('ABC_D19-0', 'ABC_D19-1'),
24 ('ABC_D19-19', 'ABC_D19-20'),
25 ('ABC_D19A-1', 'ABC_D19A-2'),
26 ('ABC_D19A-1.0', 'ABC_D19A-1.1'),
27 ('ABC_D20-0', 'ABC_D20-1')
29 @mock.patch('tools.releasereader.Executor')
30 def test_next_release(mock_exec, curr_release, next_release):
31 mock_exec.return_value.run.return_value = Result(0, curr_release + '\n', '')
32 assert ReleaseReader('test-path').get_next_release_label() == next_release
33 mock_exec.assert_called_once_with(chdir='test-path')
34 mock_exec.return_value.run.assert_called_once_with(['git', 'describe', '--tags', '--abbrev=0'])