forked from hashicorp/packer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command_test.go
44 lines (36 loc) · 861 Bytes
/
command_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package command
import (
"bytes"
"path/filepath"
"testing"
"github.com/mitchellh/packer/packer"
)
const fixturesDir = "./test-fixtures"
func fatalCommand(t *testing.T, m Meta) {
ui := m.Ui.(*packer.BasicUi)
out := ui.Writer.(*bytes.Buffer)
err := ui.ErrorWriter.(*bytes.Buffer)
t.Fatalf(
"Bad exit code.\n\nStdout:\n\n%s\n\nStderr:\n\n%s",
out.String(),
err.String())
}
func outputCommand(t *testing.T, m Meta) (string, string) {
ui := m.Ui.(*packer.BasicUi)
out := ui.Writer.(*bytes.Buffer)
err := ui.ErrorWriter.(*bytes.Buffer)
return out.String(), err.String()
}
func testFixture(n string) string {
return filepath.Join(fixturesDir, n)
}
func testMeta(t *testing.T) Meta {
var out, err bytes.Buffer
return Meta{
CoreConfig: packer.TestCoreConfig(t),
Ui: &packer.BasicUi{
Writer: &out,
ErrorWriter: &err,
},
}
}