mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-22 07:51:39 -04:00
32 lines
758 B
Go
32 lines
758 B
Go
package plugin
|
|
|
|
import (
|
|
"cgl.tideland.biz/asserts"
|
|
"os/exec"
|
|
"testing"
|
|
)
|
|
|
|
func TestCommand_NoExist(t *testing.T) {
|
|
assert := asserts.NewTestingAsserts(t, true)
|
|
|
|
_, err := Command(exec.Command("i-should-never-ever-ever-exist"))
|
|
assert.NotNil(err, "should have an error")
|
|
}
|
|
|
|
func TestCommand_Good(t *testing.T) {
|
|
assert := asserts.NewTestingAsserts(t, true)
|
|
|
|
command, err := Command(helperProcess("command"))
|
|
assert.Nil(err, "should start command properly")
|
|
|
|
result := command.Synopsis()
|
|
assert.Equal(result, "1", "should return result")
|
|
}
|
|
|
|
func TestCommand_CommandExited(t *testing.T) {
|
|
assert := asserts.NewTestingAsserts(t, true)
|
|
|
|
_, err := Command(helperProcess("im-a-command-that-doesnt-work"))
|
|
assert.NotNil(err, "should have an error")
|
|
}
|