packer-cn/packer/cmd_datasource_test.go

27 lines
491 B
Go
Raw Permalink Normal View History

package packer
2021-01-20 04:37:16 -05:00
import (
"os/exec"
"testing"
)
func TestDatasource_NoExist(t *testing.T) {
c := NewClient(&PluginClientConfig{Cmd: exec.Command("i-should-not-exist")})
2021-01-20 04:37:16 -05:00
defer c.Kill()
_, err := c.Datasource()
if err == nil {
t.Fatal("should have error")
}
}
func TestDatasource_Good(t *testing.T) {
c := NewClient(&PluginClientConfig{Cmd: helperProcess("datasource")})
2021-01-20 04:37:16 -05:00
defer c.Kill()
_, err := c.Datasource()
if err != nil {
t.Fatalf("should not have error: %s", err)
}
}