packer-cn/packer/plugin/datasource_test.go
2021-01-20 10:37:16 +01:00

27 lines
479 B
Go

package plugin
import (
"os/exec"
"testing"
)
func TestDatasource_NoExist(t *testing.T) {
c := NewClient(&ClientConfig{Cmd: exec.Command("i-should-not-exist")})
defer c.Kill()
_, err := c.Datasource()
if err == nil {
t.Fatal("should have error")
}
}
func TestDatasource_Good(t *testing.T) {
c := NewClient(&ClientConfig{Cmd: helperProcess("datasource")})
defer c.Kill()
_, err := c.Datasource()
if err != nil {
t.Fatalf("should not have error: %s", err)
}
}