updated test to remove old DefaultTmpDir reference

Fixed sudo logic
Fixed error message format issue for OSType check
This commit is contained in:
Dave Sanderson 2017-12-12 11:49:10 -07:00
parent 0efda50354
commit 630b7466d6
2 changed files with 5 additions and 4 deletions

View File

@ -130,7 +130,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
var ok bool
p.guestOSTypeConfig, ok = guestOSTypeConfigs[p.config.GuestOSType]
if !ok {
return fmt.Errorf("Invalid guest_os_type: \"$\"", p.config.GuestOSType)
return fmt.Errorf("Invalid guest_os_type: \"%s\"", p.config.GuestOSType)
}
p.guestCommands, err = provisioner.NewGuestCommands(p.config.GuestOSType, !p.config.DisableSudo)
@ -356,7 +356,7 @@ func (p *Provisioner) Cancel() {
// Prepends sudo to supplied command if config says to
func (p *Provisioner) sudo(cmd string) string {
if p.config.DisableSudo || p.config.GuestOSType != provisioner.WindowsOSType {
if p.config.DisableSudo || (p.config.GuestOSType == provisioner.WindowsOSType) {
return cmd
}

View File

@ -1,11 +1,12 @@
package saltmasterless
import (
"github.com/hashicorp/packer/packer"
"io/ioutil"
"os"
"strings"
"testing"
"github.com/hashicorp/packer/packer"
)
func testConfig() map[string]interface{} {
@ -31,7 +32,7 @@ func TestProvisionerPrepare_Defaults(t *testing.T) {
t.Fatalf("err: %s", err)
}
if p.config.TempConfigDir != DefaultTempConfigDir {
if p.config.TempConfigDir != p.guestOSTypeConfig.tempDir {
t.Errorf("unexpected temp config dir: %s", p.config.TempConfigDir)
}
}