Skip to content

Commit

Permalink
Fix tests paths for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
juliocc committed Dec 16, 2022
1 parent f428311 commit f889f65
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
9 changes: 4 additions & 5 deletions modules/iam-service-account/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ Note that this module does not fully comply with our design principles, as outpu

```hcl
module "myproject-default-service-accounts" {
source = "./fabric/modules/iam-service-account"
project_id = "myproject"
name = "vm-default"
generate_key = true
source = "./fabric/modules/iam-service-account"
project_id = "myproject"
name = "vm-default"
# authoritative roles granted *on* the service accounts to other identities
iam = {
"roles/iam.serviceAccountUser" = ["user:foo@example.com"]
Expand All @@ -24,7 +23,7 @@ module "myproject-default-service-accounts" {
]
}
}
# tftest modules=1 resources=5
# tftest modules=1 resources=4 inventory=basic.yaml
```
<!-- TFDOC OPTS files:1 -->
<!-- BEGIN TFDOC -->
Expand Down
3 changes: 2 additions & 1 deletion tests/examples/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def test_example(plan_validator, tmp_path, example):

inventory = []
if match.group(4) is not None:
inventory = BASE_PATH.parent / example.module / 'examples'
python_test_path = str(example.module).replace('-', '_')
inventory = BASE_PATH.parent / python_test_path / 'examples'
inventory = inventory / match.group(4)

# TODO: force plan_validator to never copy files (we're already
Expand Down
39 changes: 39 additions & 0 deletions tests/modules/iam_service_account/examples/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2022 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.
values:
module.myproject-default-service-accounts.google_project_iam_member.project-roles["myproject-roles/logging.logWriter"]:
condition: []
project: myproject
role: roles/logging.logWriter
module.myproject-default-service-accounts.google_project_iam_member.project-roles["myproject-roles/monitoring.metricWriter"]:
condition: []
project: myproject
role: roles/monitoring.metricWriter
module.myproject-default-service-accounts.google_service_account.service_account[0]:
account_id: vm-default
description: null
disabled: false
display_name: Terraform-managed.
project: myproject
timeouts: null
module.myproject-default-service-accounts.google_service_account_iam_binding.roles["roles/iam.serviceAccountUser"]:
condition: []
members:
- user:foo@example.com
role: roles/iam.serviceAccountUser

counts:
google_project_iam_member: 2
google_service_account: 1
google_service_account_iam_binding: 1

0 comments on commit f889f65

Please sign in to comment.