github.phpd.cn/hashicorp/packer@v1.3.2/builder/hyperv/common/step_test.go (about)

     1  package common
     2  
     3  import (
     4  	"bytes"
     5  	"os"
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	"github.com/hashicorp/packer/common/uuid"
    10  	"github.com/hashicorp/packer/helper/multistep"
    11  	"github.com/hashicorp/packer/packer"
    12  )
    13  
    14  func testState(t *testing.T) multistep.StateBag {
    15  	state := new(multistep.BasicStateBag)
    16  	state.Put("driver", new(DriverMock))
    17  	state.Put("ui", &packer.BasicUi{
    18  		Reader: new(bytes.Buffer),
    19  		Writer: new(bytes.Buffer),
    20  	})
    21  	return state
    22  }
    23  
    24  // Generates an absolute path to a directory under OS temp with a name
    25  // beginning with prefix and a UUID appended to the end
    26  func genTestDirPath(prefix string) string {
    27  	return filepath.Join(os.TempDir(), prefix+"-"+uuid.TimeOrderedUUID())
    28  }