packer-cn/builder/azure/chroot/packerui_test.go

20 lines
438 B
Go
Raw Normal View History

2020-03-25 14:08:09 -04:00
package chroot
import (
"io/ioutil"
"strings"
2020-12-17 16:29:25 -05:00
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
2020-03-25 14:08:09 -04:00
)
// testUI returns a test ui plus a function to retrieve the errors written to the ui
func testUI() (packersdk.Ui, func() string) {
2020-03-25 14:08:09 -04:00
errorBuffer := &strings.Builder{}
ui := &packersdk.BasicUi{
2020-03-25 14:08:09 -04:00
Reader: strings.NewReader(""),
Writer: ioutil.Discard,
ErrorWriter: errorBuffer,
}
return ui, errorBuffer.String
}