Terratest 介绍
Terratest 是一个开源的 Go 语言库,可更轻松地为基础设施代码编写自动化测试。它为通用基础设施的测试任务提供了各种帮助函数和模式,其中包括:
这里有一个简单的例子来说明如何测试一些 terraform 代码:
terraformOptions := &terraform.Options { // The path to where your terraform code is located terraformDir: "../examples/terraform-basic-example", } // At the end of the test, run `terraform destroy` to clean up any resources that were created defer terraform.Destroy(t, terraformOptions) // This will run `terraform init` and `terraform apply` and fail the test if there are any errors terraform.InitAndApply(t, terraformOptions) // Validate your code works as expected validateServerIsWorking(t, terraformOptions)
Terratest 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。