2014-10-28 18:09:22 -04:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
2015-05-23 19:30:45 -04:00
|
|
|
"bytes"
|
2014-10-28 22:29:51 -04:00
|
|
|
"path/filepath"
|
2014-10-28 18:09:22 -04:00
|
|
|
"testing"
|
|
|
|
|
2015-05-23 19:30:45 -04:00
|
|
|
"github.com/mitchellh/packer/packer"
|
2014-10-28 18:09:22 -04:00
|
|
|
)
|
|
|
|
|
2014-10-28 22:29:51 -04:00
|
|
|
const fixturesDir = "./test-fixtures"
|
|
|
|
|
|
|
|
func fatalCommand(t *testing.T, m Meta) {
|
2015-05-23 19:30:45 -04:00
|
|
|
ui := m.Ui.(*packer.BasicUi)
|
|
|
|
out := ui.Writer.(*bytes.Buffer)
|
|
|
|
err := ui.ErrorWriter.(*bytes.Buffer)
|
2014-10-28 22:29:51 -04:00
|
|
|
t.Fatalf(
|
|
|
|
"Bad exit code.\n\nStdout:\n\n%s\n\nStderr:\n\n%s",
|
2015-05-23 19:30:45 -04:00
|
|
|
out.String(),
|
|
|
|
err.String())
|
2014-10-28 22:29:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func testFixture(n string) string {
|
|
|
|
return filepath.Join(fixturesDir, n)
|
|
|
|
}
|
|
|
|
|
2014-10-28 18:09:22 -04:00
|
|
|
func testMeta(t *testing.T) Meta {
|
2015-05-23 19:30:45 -04:00
|
|
|
var out, err bytes.Buffer
|
|
|
|
|
2014-10-28 18:09:22 -04:00
|
|
|
return Meta{
|
2015-05-23 19:30:45 -04:00
|
|
|
Ui: &packer.BasicUi{
|
|
|
|
Writer: &out,
|
|
|
|
ErrorWriter: &err,
|
|
|
|
},
|
2014-10-28 18:09:22 -04:00
|
|
|
}
|
|
|
|
}
|