# 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.
"""Full test of cipd_upload module."""

from recipe_engine.config import List
from recipe_engine.recipe_api import Property

DEPS = [
    'pigweed/cipd_upload',
    'recipe_engine/path',
    'recipe_engine/platform',
    'recipe_engine/properties',
]

PROPERTIES = {
    'add_platform': Property(kind=bool, default=True),
    'package_paths': Property(kind=List(str), default=()),
    'package_root': Property(kind=str, default=None),
    'path': Property(kind=str, default='foo/bar/baz'),
    'repository': Property(
        kind=str, default='https://pigweed.googlesource.com/pigweed/pigweed'
    ),
    'search_tag_key': Property(kind=str, default='key'),
    'search_tag_value': Property(kind=str, default='value'),
}


def RunSteps(
    api,
    add_platform,
    package_paths,
    package_root,
    path,
    repository,
    search_tag_key,
    search_tag_value,
):  # pylint: disable=invalid-name
    """Run test steps."""

    package_root = api.path['start_dir'].join(package_root or 'pkgroot')

    metadata = [('abc', '123')]

    api.cipd_upload(
        add_platform=add_platform,
        metadata=metadata,
        paths=package_paths,
        package_root=package_root,
        cipd_path=path,
        repository=repository,
        search_tag={search_tag_key: search_tag_value},
    )


def GenTests(api):  # pylint: disable=invalid-name
    """Define tests."""

    yield (
        api.test('found')
        + api.platform('linux', 64)
        + api.cipd_upload.search_results('foo/bar/baz key:value', instances=1)
    )

    yield (
        api.test('upload')
        + api.platform('linux', 64)
        + api.cipd_upload.search_results('foo/bar/baz key:value', instances=0)
    )

    yield (
        api.test('extra_tags')
        + api.properties(extra_tags={'abc': '123'})
        + api.platform('linux', 64)
        + api.cipd_upload.search_results('foo/bar/baz key:value', instances=0)
    )
