Skip to content

Commit ef6dc39

Browse files
committed
Update test - remove steps that are impossible to perform with inmem state storage.
1 parent e57af7d commit ef6dc39

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

internal/command/e2etest/primary_test.go

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,8 @@ func TestPrimary_stateStore(t *testing.T) {
247247

248248
tf := e2e.NewBinary(t, terraformBin, "testdata/full-workflow-with-state-store")
249249

250-
// In order to do a decent end-to-end test for this case we will need a real
251-
// enough provider plugin to try to run and make sure we are able to
252-
// actually run it. Here will build the simple and simple6 (built with
253-
// protocol v6) providers.
250+
// In order to test integration with PSS we need a provider plugin implementing a state store.
251+
// Here will build the simple6 (built with protocol v6) provider, which implements PSS.
254252
simple6Provider := filepath.Join(tf.WorkDir(), "terraform-provider-simple6")
255253
simple6ProviderExe := e2e.GoBuild("github.com/hashicorp/terraform/internal/provider-simple-v6/main", simple6Provider)
256254

@@ -280,7 +278,7 @@ func TestPrimary_stateStore(t *testing.T) {
280278

281279
//// APPLY
282280
// TODO - allow apply to use state store. Otherwise this step fails as it's trying to migrate from PSS=>local backend
283-
stdout, stderr, err = tf.Run("apply", "-no-color")
281+
stdout, stderr, err = tf.Run("apply", "-auto-approve", "-no-color")
284282
if err != nil {
285283
t.Fatalf("unexpected apply error: %s\nstderr:\n%s", err, stderr)
286284
}
@@ -289,28 +287,8 @@ func TestPrimary_stateStore(t *testing.T) {
289287
t.Errorf("incorrect apply tally; want 1 added:\n%s", stdout)
290288
}
291289

292-
// INSPECT STATE
293-
stdout, stderr, err = tf.Run("state", "list")
294-
295-
//// DESTROY
296-
stdout, stderr, err = tf.Run("destroy", "-auto-approve")
297-
if err != nil {
298-
t.Fatalf("unexpected destroy error: %s\nstderr:\n%s", err, stderr)
299-
}
300-
301-
if !strings.Contains(stdout, "Resources: 1 destroyed") {
302-
t.Errorf("incorrect destroy tally; want 1 destroyed:\n%s", stdout)
303-
}
304-
305-
state, err := tf.LocalState()
306-
if err != nil {
307-
t.Fatalf("failed to read state file after destroy: %s", err)
308-
}
309-
310-
stateResources := state.RootModule().Resources
311-
if len(stateResources) != 0 {
312-
t.Errorf("wrong resources in state after destroy; want none, but still have:%s", spew.Sdump(stateResources))
313-
}
290+
// We cannot inspect state or perform a destroy here, as the state isn't persisted between steps
291+
// when we use the simple6_inmem state store.
314292
}
315293

316294
// TODO: TestPrimarySeparatePlan_stateStore - once support for PSS in plan files is implemented

0 commit comments

Comments
 (0)