# Copyright 2020 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Test of label functionality of roll_util."""

DEPS = [
    'pigweed/roll_util',
    'recipe_engine/step',
]


def RunSteps(api):
    if api.roll_util.labels_to_set:
        with api.step.nest('labels_to_set') as pres:
            pres.step_summary_text = repr(api.roll_util.labels_to_set)
    if api.roll_util.labels_to_wait_on:
        with api.step.nest('labels_to_wait_on') as pres:
            pres.step_summary_text = repr(api.roll_util.labels_to_wait_on)

    assert api.roll_util.test_api.format_prefix('foo') == 'foo.'
    assert (
        api.roll_util.normalize_remote('../foo', 'sso://host/bar')
        == 'https://host.googlesource.com/foo'
    )


def GenTests(api):
    yield (
        api.test('labels')
        + api.roll_util.properties(
            labels_to_set={'Trigger': 1, 'Foo': 123},
            labels_to_wait_on=['Verified', 'Good'],
        )
    )
