cloud-foundation-fabric/tests/modules/naming_convention/test_plan.py

57 lines
2.0 KiB
Python

# Copyright 2021 Google LLC
#
# 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
#
# http://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.
import os
import pytest
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'fixture')
def test_no_prefix_suffix(apply_runner):
_, output = apply_runner(FIXTURES_DIR)
assert output['names']['project']['tf'] == 'cloud-dev-tf'
assert output['names']['bucket']['tf-org'] == 'cloud-dev-tf-org'
assert output['labels']['project']['tf'] == {
'environment': 'dev', 'scope': 'global', 'team': 'cloud'}
assert output['labels']['bucket']['tf-org'] == {
'environment': 'dev', 'team': 'cloud'}
def test_prefix(apply_runner):
_, output = apply_runner(FIXTURES_DIR, prefix='myco')
assert output['names']['project']['tf'] == 'myco-cloud-dev-tf'
assert output['names']['bucket']['tf-org'] == 'myco-cloud-dev-tf-org'
def test_suffix(apply_runner):
_, output = apply_runner(FIXTURES_DIR, suffix='myco')
assert output['names']['project']['tf'] == 'cloud-dev-tf-myco'
assert output['names']['bucket']['tf-org'] == 'cloud-dev-tf-org-myco'
def test_resource_prefix(apply_runner):
_, output = apply_runner(FIXTURES_DIR, prefix='myco',
use_resource_prefixes='true')
assert output['names']['project']['tf'] == 'project-myco-cloud-dev-tf'
assert output['names']['bucket']['tf-org'] == 'bucket-myco-cloud-dev-tf-org'
def test_separator(apply_runner):
_, output = apply_runner(
FIXTURES_DIR, separator_override='{ dataset = "_" }')
assert output['names']['dataset'] == {
'foobar': 'cloud_dev_foobar', 'frobniz': 'cloud_dev_frobniz'}