@@ -115,6 +115,7 @@ func TestInit_two_step_provider_download(t *testing.T) {
115115
116116 cases := map [string ]struct {
117117 workDirPath string
118+ flags []string
118119 expectedDownloadMsgs []string
119120 }{
120121 "providers required by only the state file" : {
@@ -173,6 +174,21 @@ func TestInit_two_step_provider_download(t *testing.T) {
173174 - Using previously-installed hashicorp/random v1.0.0` ,
174175 },
175176 },
177+ "using the -upgrade flag causes provider download to ignore the lock file" : {
178+ workDirPath : "init-provider-download/config-state-file-and-lockfile" ,
179+ flags : []string {"-upgrade" },
180+ expectedDownloadMsgs : []string {
181+ // Config - lock file is not mentioned due to the -upgrade flag
182+ `Initializing provider plugins found in the configuration...
183+ - Finding hashicorp/random versions matching "< 9.0.0"...
184+ - Installing hashicorp/random v1.0.0...
185+ - Installed hashicorp/random v1.0.0` ,
186+ // State - reuses the provider download from the config
187+ `Initializing provider plugins found in the state...
188+ - Reusing previous version of hashicorp/random from the dependency lock file
189+ - Using previously-installed hashicorp/random v1.0.0` ,
190+ },
191+ },
176192 }
177193
178194 for tn , tc := range cases {
@@ -204,7 +220,7 @@ func TestInit_two_step_provider_download(t *testing.T) {
204220 },
205221 }
206222
207- args := [] string { "-enable-pluggable-state-storage-experiment" } // Needed to test init changes for PSS project
223+ args := append ( tc . flags , "-enable-pluggable-state-storage-experiment" ) // Needed to test init changes for PSS project
208224 if code := c .Run (args ); code != 0 {
209225 t .Fatalf ("bad: \n %s" , done (t ).All ())
210226 }
0 commit comments