Skip to content

Commit

Permalink
Add failing test replicating #4013
Browse files Browse the repository at this point in the history
  • Loading branch information
jen20 committed Nov 23, 2015
1 parent 5ec4467 commit 890e214
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
29 changes: 29 additions & 0 deletions command/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"testing"

"bytes"
"github.com/hashicorp/terraform/terraform"
"github.com/mitchellh/cli"
)
Expand Down Expand Up @@ -413,6 +414,34 @@ func TestRefresh_varFileDefault(t *testing.T) {
}
}

func TestRefresh_varsUnset(t *testing.T) {
// Disable test mode so input would be asked
test = false
defer func() { test = true }()

defaultInputReader = bytes.NewBufferString("bar\n")

state := testState()
statePath := testStateFile(t, state)

p := testProvider()
ui := new(cli.MockUi)
c := &RefreshCommand{
Meta: Meta{
ContextOpts: testCtxConfig(p),
Ui: ui,
},
}

args := []string{
"-state", statePath,
testFixturePath("refresh-unset-var"),
}
if code := c.Run(args); code != 0 {
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
}
}

func TestRefresh_backup(t *testing.T) {
state := testState()
statePath := testStateFile(t, state)
Expand Down
7 changes: 7 additions & 0 deletions command/test-fixtures/refresh-unset-var/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "should_ask" {}

provider "test" {}

resource "test_instance" "foo" {
ami = "${var.should_ask}"
}

0 comments on commit 890e214

Please sign in to comment.