gpt4 book ai didi

amazon-web-services - 用于检查资源标签的 Clarity Terraform 测试

转载 作者:行者123 更新时间:2023-12-04 15:24:56 25 4
gpt4 key购买 nike

我是净度测试工具的新手。我想知道是否可以使用 clarity 来检查标签是否添加到 AWS 资源。

我为如下标签编写了清晰度测试:

Scenario: EC2 should have tag "application"
Given Terraform
And a "aws_instance" of type "resource"
And "our component is <tag-key>"
When attribute "tags" exists
Then attribute "tags" matches regex "tags.*<tag-key>*"

Examples:
| tag-key |
| Name |
| application |

但是我得到以下错误:

Feature: EC2 should have encrypted EBS volume attached

Scenario: EC2 should have tag "application" # main.feature:3
Given Terraform # terraform.go:92 -> *Match
And a "aws_instance" of type "resource" # terraform.go:279 -> *Match
And "our component is <tag-key>" # clarity_test.go:49 -> noopComment
Then attribute "tags" exists # terraform.go:304 -> *Match
Then attribute "tags" matches regex "<tag-key>"

Examples:
| tag-key |
| Name |
| application |

2 scenarios (2 undefined)
10 steps (8 passed, 2 undefined)
1.849441ms

You can implement step definitions for undefined steps with these snippets:

func attributeMatchesRegex(arg1, arg2 string) error {
return godog.ErrPending
}

func FeatureContext(s *godog.Suite) {
s.Step(`^attribute "([^"]*)" matches regex "([^"]*)"$`, attributeMatchesRegex)
}

这里的任何建议都会有所帮助。

问候,

科技女孩

最佳答案

令人遗憾的是,关于清晰度的文档非常少,而且它没有提到如何为类型映射属性中的条目编写匹配器。 Clarity 自己的测试套件中也没有针对这种匹配器的示例。

我找不到具体的答案,但这可能有效(调整你的匹配器以匹配标签名称的存在):

Then attribute "tags.<tag-key>" exists

关于amazon-web-services - 用于检查资源标签的 Clarity Terraform 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62472469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com