|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bytes"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"net/http"
|
|
|
|
|
@ -123,7 +124,7 @@ func TestZeroThirteenUpgrade_success(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if code := c.Run(nil); code != 0 {
|
|
|
|
|
if code := c.Run([]string{"-yes"}); code != 0 {
|
|
|
|
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -173,7 +174,7 @@ func TestZeroThirteenUpgrade_submodule(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Here we pass a target module directory to process
|
|
|
|
|
if code := c.Run([]string{"module"}); code != 0 {
|
|
|
|
|
if code := c.Run([]string{"-yes", "module"}); code != 0 {
|
|
|
|
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -203,7 +204,7 @@ func TestZeroThirteenUpgrade_skippedFiles(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if code := c.Run(nil); code != 0 {
|
|
|
|
|
if code := c.Run([]string{"-yes"}); code != 0 {
|
|
|
|
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -221,6 +222,67 @@ func TestZeroThirteenUpgrade_skippedFiles(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestZeroThirteenUpgrade_confirm(t *testing.T) {
|
|
|
|
|
inputPath := testFixturePath(path.Join("013upgrade-explicit-providers", "input"))
|
|
|
|
|
|
|
|
|
|
td := tempDir(t)
|
|
|
|
|
copy.CopyDir(inputPath, td)
|
|
|
|
|
defer os.RemoveAll(td)
|
|
|
|
|
defer testChdir(t, td)()
|
|
|
|
|
|
|
|
|
|
ui := new(cli.MockUi)
|
|
|
|
|
inputBuf := &bytes.Buffer{}
|
|
|
|
|
ui.InputReader = inputBuf
|
|
|
|
|
inputBuf.WriteString("yes")
|
|
|
|
|
c := &ZeroThirteenUpgradeCommand{
|
|
|
|
|
Meta: Meta{
|
|
|
|
|
testingOverrides: metaOverridesForProvider(testProvider()),
|
|
|
|
|
Ui: ui,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if code := c.Run(nil); code != 0 {
|
|
|
|
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output := ui.OutputWriter.String()
|
|
|
|
|
if !strings.Contains(output, "Upgrade complete") {
|
|
|
|
|
t.Fatal("unexpected output:", output)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestZeroThirteenUpgrade_cancel(t *testing.T) {
|
|
|
|
|
inputPath := testFixturePath(path.Join("013upgrade-explicit-providers", "input"))
|
|
|
|
|
|
|
|
|
|
td := tempDir(t)
|
|
|
|
|
copy.CopyDir(inputPath, td)
|
|
|
|
|
defer os.RemoveAll(td)
|
|
|
|
|
defer testChdir(t, td)()
|
|
|
|
|
|
|
|
|
|
ui := new(cli.MockUi)
|
|
|
|
|
inputBuf := &bytes.Buffer{}
|
|
|
|
|
ui.InputReader = inputBuf
|
|
|
|
|
inputBuf.WriteString("no")
|
|
|
|
|
c := &ZeroThirteenUpgradeCommand{
|
|
|
|
|
Meta: Meta{
|
|
|
|
|
testingOverrides: metaOverridesForProvider(testProvider()),
|
|
|
|
|
Ui: ui,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if code := c.Run(nil); code != 0 {
|
|
|
|
|
t.Fatalf("bad: \n%s", ui.ErrorWriter.String())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output := ui.OutputWriter.String()
|
|
|
|
|
if !strings.Contains(output, "Upgrade cancelled") {
|
|
|
|
|
t.Fatal("unexpected output:", output)
|
|
|
|
|
}
|
|
|
|
|
if strings.Contains(output, "Upgrade complete") {
|
|
|
|
|
t.Fatal("unexpected output:", output)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestZeroThirteenUpgrade_unsupportedVersion(t *testing.T) {
|
|
|
|
|
inputPath := testFixturePath("013upgrade-unsupported-version")
|
|
|
|
|
|
|
|
|
|
@ -237,7 +299,7 @@ func TestZeroThirteenUpgrade_unsupportedVersion(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if code := c.Run(nil); code == 0 {
|
|
|
|
|
if code := c.Run([]string{"-yes"}); code == 0 {
|
|
|
|
|
t.Fatal("expected error, got:", ui.OutputWriter)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -309,7 +371,7 @@ func TestZeroThirteenUpgrade_empty(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if code := c.Run(nil); code == 0 {
|
|
|
|
|
if code := c.Run([]string{"-yes"}); code == 0 {
|
|
|
|
|
t.Fatal("expected error, got:", ui.OutputWriter)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|