github.com/hashicorp/packer@v1.14.3/packer/cmd_datasource_test.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package packer
     5  
     6  import (
     7  	"os/exec"
     8  	"testing"
     9  )
    10  
    11  func TestDatasource_NoExist(t *testing.T) {
    12  	c := NewClient(&PluginClientConfig{Cmd: exec.Command("i-should-not-exist")})
    13  	defer c.Kill()
    14  
    15  	_, err := c.Datasource()
    16  	if err == nil {
    17  		t.Fatal("should have error")
    18  	}
    19  }
    20  
    21  func TestDatasource_Good(t *testing.T) {
    22  	c := NewClient(&PluginClientConfig{Cmd: helperProcess("datasource")})
    23  	defer c.Kill()
    24  
    25  	_, err := c.Datasource()
    26  	if err != nil {
    27  		t.Fatalf("should not have error: %s", err)
    28  	}
    29  }