github.com/emate/packer@v0.8.1-0.20150625195101-fe0fde195dc6/command/command_test.go (about)

     1  package command
     2  
     3  import (
     4  	"bytes"
     5  	"path/filepath"
     6  	"testing"
     7  
     8  	"github.com/mitchellh/packer/packer"
     9  )
    10  
    11  const fixturesDir = "./test-fixtures"
    12  
    13  func fatalCommand(t *testing.T, m Meta) {
    14  	ui := m.Ui.(*packer.BasicUi)
    15  	out := ui.Writer.(*bytes.Buffer)
    16  	err := ui.ErrorWriter.(*bytes.Buffer)
    17  	t.Fatalf(
    18  		"Bad exit code.\n\nStdout:\n\n%s\n\nStderr:\n\n%s",
    19  		out.String(),
    20  		err.String())
    21  }
    22  
    23  func testFixture(n string) string {
    24  	return filepath.Join(fixturesDir, n)
    25  }
    26  
    27  func testMeta(t *testing.T) Meta {
    28  	var out, err bytes.Buffer
    29  
    30  	return Meta{
    31  		CoreConfig: packer.TestCoreConfig(t),
    32  		Ui: &packer.BasicUi{
    33  			Writer:      &out,
    34  			ErrorWriter: &err,
    35  		},
    36  	}
    37  }