Skip to content

Commit

Permalink
add basic e2e tests for state push/pull
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoe committed Jun 27, 2022
1 parent 65b947d commit dec257b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tfexec/internal/e2etest/state_pull_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package e2etest

import (
"context"
"testing"

"github.com/hashicorp/go-version"

"github.com/hashicorp/terraform-exec/tfexec"
)

func TestStatePull(t *testing.T) {
runTest(t, "basic_with_state", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
if tfv.LessThan(providerAddressMinVersion) {
t.Skip("state file provider FQNs not compatible with this Terraform version")
}

err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
}

_, err = tf.StatePull(context.Background())
if err != nil {
t.Fatalf("error running StatePull: %s", err)
}
})
}
28 changes: 28 additions & 0 deletions tfexec/internal/e2etest/state_push_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package e2etest

import (
"context"
"testing"

"github.com/hashicorp/go-version"

"github.com/hashicorp/terraform-exec/tfexec"
)

func TestStatePush(t *testing.T) {
runTest(t, "basic_with_state", func(t *testing.T, tfv *version.Version, tf *tfexec.Terraform) {
if tfv.LessThan(providerAddressMinVersion) {
t.Skip("state file provider FQNs not compatible with this Terraform version")
}

err := tf.Init(context.Background())
if err != nil {
t.Fatalf("error running Init in test directory: %s", err)
}

err = tf.StatePush(context.Background(), "terraform.tfstate")
if err != nil {
t.Fatalf("error running StatePush: %s", err)
}
})
}

0 comments on commit dec257b

Please sign in to comment.