Skip to content

Commit b0b80c3

Browse files
added terra test for azure dta share
1 parent 061e89d commit b0b80c3

File tree

7 files changed

+222
-0
lines changed

7 files changed

+222
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module "data_share" {
2+
source = "../../" # points to the module root (azure-data-share)
3+
4+
resource_group_name = var.resource_group_name
5+
location = var.location
6+
data_share_name = var.data_share_name
7+
8+
environment = var.environment
9+
application_name = var.application_name
10+
temporary = var.temporary
11+
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
output "azure_datashare_rg" {
2+
value = module.data_share.azure_datashare_rg
3+
}
4+
5+
output "datashare_name" {
6+
value = module.data_share.datashare_name
7+
}
8+
9+
output "datashare_id" {
10+
value = module.data_share.datashare_id
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = ">= 3.0.0"
6+
}
7+
}
8+
}
9+
10+
provider "azurerm" {
11+
features {}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
variable "resource_group_name" { type = string }
2+
variable "location" { type = string }
3+
variable "data_share_name" { type = string }
4+
5+
variable "environment" { type = string }
6+
variable "application_name" { type = string }
7+
variable "temporary" { type = string }
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package test
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
"testing"
7+
"time"
8+
9+
"github.com/gruntwork-io/terratest/modules/terraform"
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestAzureDataShareModule(t *testing.T) {
14+
t.Parallel()
15+
16+
// create unique suffix so tests don't collide
17+
suffix := "go"
18+
rgName := fmt.Sprintf("rg-terratest-%s", suffix)
19+
dataShareName := fmt.Sprintf("ds-terratest-%s", suffix)
20+
// scheduleName := fmt.Sprintf("sched-terratest-%s", suffix)
21+
// RFC3339-ish timestamp for snapshot_start_time
22+
// snapshotStart := time.Now().UTC().Add(1 * time.Hour).Format(time.RFC3339)
23+
24+
terraformOptions := &terraform.Options{
25+
// Path to the example usage of the module
26+
TerraformDir: "../examples/simple",
27+
28+
Vars: map[string]interface{}{
29+
"resource_group_name": rgName,
30+
"location": "centralindia",
31+
"data_share_name": dataShareName,
32+
33+
// module tags/metadata
34+
"environment": "DEV",
35+
"application_name": "devwithkrishna",
36+
"temporary": "TRUE",
37+
38+
// // share-specific args (safe defaults)
39+
// "share_name": dataShareName,
40+
// "share_type": "CopyBased",
41+
// "share_description": "Terratest-created data share",
42+
// "datashare_terms": "Test terms",
43+
44+
// snapshot schedule (the module's validation requires a value)
45+
// "snapshot_schedule_name": scheduleName,
46+
// "snapshot_recurrence": "Hour",
47+
// "snapshot_start_time": snapshotStart,
48+
},
49+
50+
// Retry settings: Azure sometimes needs extra time for provisioning
51+
MaxRetries: 3,
52+
TimeBetweenRetries: 10 * time.Second,
53+
}
54+
55+
// ensure cleanup
56+
defer terraform.Destroy(t, terraformOptions)
57+
58+
// init + apply
59+
terraform.InitAndApply(t, terraformOptions)
60+
61+
// read outputs
62+
rgOut := terraform.Output(t, terraformOptions, "azure_datashare_rg")
63+
dsNameOut := terraform.Output(t, terraformOptions, "datashare_name")
64+
dsIDOut := terraform.Output(t, terraformOptions, "datashare_id")
65+
66+
t.Logf("Outputs: rg=%s, datashare=%s, id=%s", rgOut, dsNameOut, dsIDOut)
67+
68+
// basic assertions
69+
assert.Equal(t, rgName, rgOut)
70+
assert.Equal(t, dataShareName, dsNameOut)
71+
assert.NotEmpty(t, dsIDOut)
72+
assert.True(t, strings.Contains(dsIDOut, "/resourceGroups/"))
73+
}

azure-data-share/test/go.mod

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module github.com/devwithkrishna/azure-data-share/test
2+
3+
go 1.24.0
4+
5+
toolchain go1.24.8
6+
7+
require (
8+
github.com/agext/levenshtein v1.2.3 // indirect
9+
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
10+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
11+
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/gruntwork-io/terratest v0.51.0 // indirect
13+
github.com/hashicorp/errwrap v1.0.0 // indirect
14+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
15+
github.com/hashicorp/go-getter/v2 v2.2.3 // indirect
16+
github.com/hashicorp/go-multierror v1.1.1 // indirect
17+
github.com/hashicorp/go-safetemp v1.0.0 // indirect
18+
github.com/hashicorp/go-version v1.7.0 // indirect
19+
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
20+
github.com/hashicorp/terraform-json v0.23.0 // indirect
21+
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
22+
github.com/klauspost/compress v1.16.5 // indirect
23+
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
24+
github.com/mitchellh/go-homedir v1.1.0 // indirect
25+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
26+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
27+
github.com/pmezard/go-difflib v1.0.0 // indirect
28+
github.com/stretchr/testify v1.11.1 // indirect
29+
github.com/tmccombs/hcl2json v0.6.4 // indirect
30+
github.com/ulikunitz/xz v0.5.10 // indirect
31+
github.com/zclconf/go-cty v1.15.0 // indirect
32+
golang.org/x/crypto v0.36.0 // indirect
33+
golang.org/x/mod v0.21.0 // indirect
34+
golang.org/x/net v0.38.0 // indirect
35+
golang.org/x/sync v0.12.0 // indirect
36+
golang.org/x/sys v0.31.0 // indirect
37+
golang.org/x/text v0.23.0 // indirect
38+
golang.org/x/tools v0.26.0 // indirect
39+
gopkg.in/yaml.v3 v3.0.1 // indirect
40+
)

azure-data-share/test/go.sum

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
2+
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
3+
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
4+
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
5+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
6+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
7+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
8+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9+
github.com/gruntwork-io/terratest v0.51.0 h1:RCXlCwWlHqhUoxgF6n3hvywvbvrsTXqoqt34BrnLekw=
10+
github.com/gruntwork-io/terratest v0.51.0/go.mod h1:evZHXb8VWDgv5O5zEEwfkwMhkx9I53QR/RB11cISrpg=
11+
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
12+
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
13+
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
14+
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
15+
github.com/hashicorp/go-getter/v2 v2.2.3 h1:6CVzhT0KJQHqd9b0pK3xSP0CM/Cv+bVhk+jcaRJ2pGk=
16+
github.com/hashicorp/go-getter/v2 v2.2.3/go.mod h1:hp5Yy0GMQvwWVUmwLs3ygivz1JSLI323hdIE9J9m7TY=
17+
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
18+
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
19+
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
20+
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
21+
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
22+
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
23+
github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M=
24+
github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
25+
github.com/hashicorp/terraform-json v0.23.0 h1:sniCkExU4iKtTADReHzACkk8fnpQXrdD2xoR+lppBkI=
26+
github.com/hashicorp/terraform-json v0.23.0/go.mod h1:MHdXbBAbSg0GvzuWazEGKAn/cyNfIB7mN6y7KJN6y2c=
27+
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a h1:zPPuIq2jAWWPTrGt70eK/BSch+gFAGrNzecsoENgu2o=
28+
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s=
29+
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
30+
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
31+
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 h1:ofNAzWCcyTALn2Zv40+8XitdzCgXY6e9qvXwN9W0YXg=
32+
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
33+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
34+
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
35+
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
36+
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
37+
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
38+
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
39+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
40+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
41+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
42+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
43+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
44+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
45+
github.com/tmccombs/hcl2json v0.6.4 h1:/FWnzS9JCuyZ4MNwrG4vMrFrzRgsWEOVi+1AyYUVLGw=
46+
github.com/tmccombs/hcl2json v0.6.4/go.mod h1:+ppKlIW3H5nsAsZddXPy2iMyvld3SHxyjswOZhavRDk=
47+
github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
48+
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
49+
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
50+
github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
51+
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
52+
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
53+
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
54+
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
55+
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
56+
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
57+
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
58+
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
59+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
60+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
61+
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
62+
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
63+
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
64+
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
65+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
66+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
67+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)