# 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 rolls of multiple repositories."""

from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:  # pragma: no cover
    from typing import Generator
    from recipe_engine import recipe_test_api

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


def RunSteps(api):
    # pylint: disable=unnecessary-lambda
    path = lambda name: api.path.start_dir / name

    rolls = [
        api.roll_util.create_roll(
            project_name='abc',
            old_revision='1' * 40,
            new_revision='4' * 40,
            proj_dir=path('abc'),
            direction=api.roll_util.Direction.FORWARD,
        ),
        api.roll_util.create_roll(
            project_name='xyz',
            old_revision='9' * 40,
            new_revision='c' * 40,
            proj_dir=path('xyz'),
            direction=api.roll_util.Direction.FORWARD,
        ),
        api.roll_util.create_roll(
            project_name='def',
            old_revision='5' * 40,
            new_revision='8' * 40,
            proj_dir=path('def'),
            direction=api.roll_util.Direction.FORWARD,
        ),
    ]

    # For coverage of Account.__lt__.
    accounts = [
        api.roll_util.Account('bb', 'bb@bb.bb'),
        api.roll_util.Account('aa', 'aa@aa.aa'),
    ]
    accounts = sorted(accounts)

    message = api.roll_util.message(*rolls)
    with api.step.nest('message') as pres:
        pres.logs['message'] = message


def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]:
    yield api.test(
        'single_commits',
        api.roll_util.commit_data('abc', api.roll_util.commit('4' * 40)),
        api.roll_util.commit_data('def', api.roll_util.commit('8' * 40)),
        api.roll_util.commit_data('xyz', api.roll_util.commit('c' * 40)),
    )

    yield api.test(
        'multiple_commits',
        api.roll_util.commit_data(
            'abc',
            api.roll_util.commit('2' * 40),
            api.roll_util.commit('3' * 40),
            api.roll_util.commit('4' * 40),
        ),
        api.roll_util.commit_data(
            'def',
            api.roll_util.commit('6' * 40),
            api.roll_util.commit('7' * 40),
            api.roll_util.commit('8' * 40),
        ),
        api.roll_util.commit_data(
            'xyz',
            api.roll_util.commit('a' * 40),
            api.roll_util.commit('b' * 40),
            api.roll_util.commit('c' * 40),
        ),
    )

    yield api.test(
        'mixed',
        api.roll_util.properties(commit_divider='--divider--'),
        api.roll_util.commit_data('abc', api.roll_util.commit('4' * 40)),
        api.roll_util.commit_data(
            'def',
            api.roll_util.commit('6' * 40),
            api.roll_util.commit('8' * 40),
        ),
        api.roll_util.commit_data(
            'xyz',
            api.roll_util.commit('a' * 40),
            api.roll_util.commit('b' * 40),
            api.roll_util.commit('c' * 40),
        ),
    )
