@@ -73,7 +73,7 @@ func TestDownloadTerraformSourceIfNecessaryLocalDirToEmptyDir(t *testing.T) {
7373 downloadDir := tmpDir (t )
7474 defer os .Remove (downloadDir )
7575
76- testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , "# Hello, World" )
76+ testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , false , "# Hello, World" )
7777}
7878
7979func TestDownloadTerraformSourceIfNecessaryLocalDirToAlreadyDownloadedDir (t * testing.T ) {
@@ -85,7 +85,7 @@ func TestDownloadTerraformSourceIfNecessaryLocalDirToAlreadyDownloadedDir(t *tes
8585
8686 copyFolder (t , "../test/fixture-download-source/hello-world-2" , downloadDir )
8787
88- testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , "# Hello, World" )
88+ testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , false , "# Hello, World" )
8989}
9090
9191func TestDownloadTerraformSourceIfNecessaryRemoteUrlToEmptyDir (t * testing.T ) {
@@ -95,7 +95,7 @@ func TestDownloadTerraformSourceIfNecessaryRemoteUrlToEmptyDir(t *testing.T) {
9595 downloadDir := tmpDir (t )
9696 defer os .Remove (downloadDir )
9797
98- testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , "# Hello, World" )
98+ testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , false , "# Hello, World" )
9999}
100100
101101func TestDownloadTerraformSourceIfNecessaryRemoteUrlToAlreadyDownloadedDir (t * testing.T ) {
@@ -107,7 +107,7 @@ func TestDownloadTerraformSourceIfNecessaryRemoteUrlToAlreadyDownloadedDir(t *te
107107
108108 copyFolder (t , "../test/fixture-download-source/hello-world-2" , downloadDir )
109109
110- testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , "# Hello, World 2" )
110+ testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , false , "# Hello, World 2" )
111111}
112112
113113func TestDownloadTerraformSourceIfNecessaryRemoteUrlToAlreadyDownloadedDirDifferentVersion (t * testing.T ) {
@@ -119,7 +119,7 @@ func TestDownloadTerraformSourceIfNecessaryRemoteUrlToAlreadyDownloadedDirDiffer
119119
120120 copyFolder (t , "../test/fixture-download-source/hello-world-2" , downloadDir )
121121
122- testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , "# Hello, World" )
122+ testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , false , "# Hello, World" )
123123}
124124
125125func TestDownloadTerraformSourceIfNecessaryRemoteUrlToAlreadyDownloadedDirSameVersion (t * testing.T ) {
@@ -131,17 +131,32 @@ func TestDownloadTerraformSourceIfNecessaryRemoteUrlToAlreadyDownloadedDirSameVe
131131
132132 copyFolder (t , "../test/fixture-download-source/hello-world-version-remote" , downloadDir )
133133
134- testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , "# Hello, World version remote" )
134+ testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , false , "# Hello, World version remote" )
135135}
136136
137- func testDownloadTerraformSourceIfNecessary (t * testing.T , canonicalUrl string , downloadDir string , expectedFileContents string ) {
137+ func TestDownloadTerraformSourceIfNecessaryRemoteUrlOverrideSource (t * testing.T ) {
138+ t .Parallel ()
139+
140+ canonicalUrl := "github.com/gruntwork-io/terragrunt//test/fixture-download-source/hello-world?ref=v0.9.7"
141+ downloadDir := tmpDir (t )
142+ defer os .Remove (downloadDir )
143+
144+ copyFolder (t , "../test/fixture-download-source/hello-world-version-remote" , downloadDir )
145+
146+ testDownloadTerraformSourceIfNecessary (t , canonicalUrl , downloadDir , true , "# Hello, World" )
147+ }
148+
149+ func testDownloadTerraformSourceIfNecessary (t * testing.T , canonicalUrl string , downloadDir string , sourceUpdate bool , expectedFileContents string ) {
138150 terraformSource := & TerraformSource {
139151 CanonicalSourceURL : parseUrl (t , canonicalUrl ),
140152 DownloadDir : downloadDir ,
141153 VersionFile : filepath .Join (downloadDir , "version-file.txt" ),
142154 }
143155
144- err := downloadTerraformSourceIfNecessary (terraformSource , options .NewTerragruntOptionsForTest ("./should-not-be-used" ))
156+ terragruntOptions := options .NewTerragruntOptionsForTest ("./should-not-be-used" )
157+ terragruntOptions .SourceUpdate = sourceUpdate
158+
159+ err := downloadTerraformSourceIfNecessary (terraformSource , terragruntOptions )
145160 assert .Nil (t , err , "For terraform source %v: %v" , terraformSource , err )
146161
147162 expectedFilePath := filepath .Join (downloadDir , "main.tf" )
0 commit comments