command: compilation works
This still isn't ready. But this gets tests passing and compilation working
This commit is contained in:
parent
9ddf73ad81
commit
f34ef1f92a
|
@ -224,21 +224,7 @@ func testProvider() *terraform.MockResourceProvider {
|
|||
}
|
||||
|
||||
func testTempFile(t *testing.T) string {
|
||||
tf, err := ioutil.TempFile("", "tf")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
result := tf.Name()
|
||||
|
||||
if err := tf.Close(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if err := os.Remove(result); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
return result
|
||||
return filepath.Join(testTempDir(t), "state.tfstate")
|
||||
}
|
||||
|
||||
func testTempDir(t *testing.T) string {
|
||||
|
|
|
@ -108,6 +108,9 @@ func TestPlan_destroy(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPlan_noState(t *testing.T) {
|
||||
tmp, cwd := testCwd(t)
|
||||
defer testFixCwd(t, tmp, cwd)
|
||||
|
||||
p := testProvider()
|
||||
ui := new(cli.MockUi)
|
||||
c := &PlanCommand{
|
||||
|
|
|
@ -3,12 +3,18 @@ package command
|
|||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/hashicorp/terraform/state"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
// StateMeta is the meta struct that should be embedded in state subcommands.
|
||||
type StateMeta struct{}
|
||||
|
||||
// State returns the state for this meta.
|
||||
func (m *StateMeta) State(cm *Meta) (state.State, error) {
|
||||
return cm.State()
|
||||
}
|
||||
|
||||
// filterInstance filters a single instance out of filter results.
|
||||
func (c *StateMeta) filterInstance(rs []*terraform.StateFilterResult) (*terraform.StateFilterResult, error) {
|
||||
var result *terraform.StateFilterResult
|
||||
|
|
|
@ -26,7 +26,7 @@ func (c *StateShowCommand) Run(args []string) int {
|
|||
}
|
||||
args = cmdFlags.Args()
|
||||
|
||||
state, err := c.State()
|
||||
state, err := c.Meta.State()
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf(errStateLoadingState, err))
|
||||
return cli.RunResultHelp
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// testStateBackups returns the list of backups in order of creation
|
||||
// (oldest first) in the given directory.
|
||||
func testStateBackups(t *testing.T, dir string) []string {
|
||||
// Find all the backups
|
||||
list, err := filepath.Glob(filepath.Join(dir, "*"+DefaultBackupExtension))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
// Sort them which will put them naturally in the right order
|
||||
sort.Strings(list)
|
||||
|
||||
return list
|
||||
}
|
Loading…
Reference in New Issue