mirror of https://github.com/ansible/ansible.git
Force collections to be static (#68723)
* Force collections to be static Templating of collection names does not work at all. Force them to be static so that a warning is generated for the user. * Add collectionsearch unit test and fix for reviews New unit test validates the new _load_collections() code and moves the new check to the end of the method. * Change unit test to pytest * Adjust unit test to use capsys instead of monkeypatch * Fix pep8 error * Add changelog fragment Closes #68704pull/68984/head^2
parent
d91658ec0c
commit
18a66e291d
@ -0,0 +1,3 @@
|
||||
bugfixes:
|
||||
- Force collection names to be static so that a warning is generated because
|
||||
templating currently does not work (see https://github.com/ansible/ansible/issues/68704).
|
@ -0,0 +1,38 @@
|
||||
# (c) 2020 Ansible Project
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.playbook.collectionsearch import CollectionSearch
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_collection_static_warning(capsys):
|
||||
"""Test that collection name is not templated.
|
||||
|
||||
Also, make sure that users see the warning message for the referenced name.
|
||||
"""
|
||||
|
||||
collection_name = 'foo.{{bar}}'
|
||||
cs = CollectionSearch()
|
||||
assert collection_name in cs._load_collections(None, [collection_name])
|
||||
|
||||
std_out, std_err = capsys.readouterr()
|
||||
assert '[WARNING]: "collections" is not templatable, but we found: %s' % collection_name in std_err
|
||||
assert '' == std_out
|
Loading…
Reference in New Issue