Skip to content

Commit b3550b2

Browse files
author
Nikita Dugar
committed
add terratest
1 parent a1e8209 commit b3550b2

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

_example/example.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module "s3_bucket" {
1818
}
1919

2020
module "sftp" {
21-
source = "git::https://github.com/clouddrove/terraform-aws-sftp.git?ref=tags/0.12.0"
21+
source = "./../"
2222
name = "sftp"
2323
application = "clouddrove"
2424
environment = "test"

_example/outputs.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
21
output "sftp" {
32
value = module.sftp.*.id
43
description = "The Server ID of the Transfer Server (e.g. s-12345678)"
54
}
5+
6+
output "tags" {
7+
value = module.sftp.tags
8+
description = "A mapping of tags to assign to the SFTP."
9+
}

_test/sftp_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Managed By : CloudDrove
2+
// Description : This Terratest is used to test the Terraform Elasticache module.
3+
// Copyright @ CloudDrove. All Right Reserved.
4+
package test
5+
6+
import (
7+
"testing"
8+
"strings"
9+
"github.com/stretchr/testify/assert"
10+
"github.com/gruntwork-io/terratest/modules/terraform"
11+
)
12+
13+
func Test(t *testing.T) {
14+
t.Parallel()
15+
16+
terraformOptions := &terraform.Options{
17+
// Source path of Terraform directory.
18+
TerraformDir: "../_example",
19+
Upgrade: true,
20+
}
21+
22+
// This will run 'terraform init' and 'terraform application' and will fail the test if any errors occur
23+
terraform.InitAndApply(t, terraformOptions)
24+
25+
// To clean up any resources that have been created, run 'terraform destroy' towards the end of the test
26+
defer terraform.Destroy(t, terraformOptions)
27+
28+
// To get the value of an output variable, run 'terraform output'
29+
Id := strings.Join(terraform.OutputList(t, terraformOptions, "id")," ")
30+
Tags := terraform.OutputMap(t, terraformOptions, "tags")
31+
32+
// Verify we're getting back the outputs we expect
33+
assert.Contains(t, Id, "s-")
34+
assert.Equal(t, "test-redis-cd", Tags["Name"])
35+
}

outputs.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#Module : SFTP
22
#Description : Terraform sftp module variables.
33

4-
output "transfer_server_id" {
4+
output "id" {
55
value = aws_transfer_server.transfer_server.*.id[0]
66
description = "The Server ID of the Transfer Server (e.g. s-12345678)."
77
}
88

99
output "transfer_server_endpoint" {
1010
value = aws_transfer_server.transfer_server.*.endpoint[0]
1111
description = "The endpoint of the Transfer Server (e.g. s-12345678.server.transfer.REGION.amazonaws.com)."
12+
}
13+
14+
output "tags" {
15+
value = module.labels.tags
16+
description = "A mapping of tags to assign to the resource."
1217
}

0 commit comments

Comments
 (0)