github.com/sneal/packer@v0.5.2/builder/vmware/common/artifact_test.go (about)

     1  package common
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	"github.com/mitchellh/packer/packer"
    10  )
    11  
    12  func TestLocalArtifact_impl(t *testing.T) {
    13  	var _ packer.Artifact = new(localArtifact)
    14  }
    15  
    16  func TestNewLocalArtifact(t *testing.T) {
    17  	td, err := ioutil.TempDir("", "packer")
    18  	if err != nil {
    19  		t.Fatalf("err: %s", err)
    20  	}
    21  	defer os.RemoveAll(td)
    22  
    23  	err = ioutil.WriteFile(filepath.Join(td, "a"), []byte("foo"), 0644)
    24  	if err != nil {
    25  		t.Fatalf("err: %s", err)
    26  	}
    27  
    28  	if err := os.Mkdir(filepath.Join(td, "b"), 0755); err != nil {
    29  		t.Fatalf("err: %s", err)
    30  	}
    31  
    32  	a, err := NewLocalArtifact(td)
    33  	if err != nil {
    34  		t.Fatalf("err: %s", err)
    35  	}
    36  
    37  	if a.BuilderId() != BuilderId {
    38  		t.Fatalf("bad: %#v", a.BuilderId())
    39  	}
    40  	if len(a.Files()) != 1 {
    41  		t.Fatalf("should length 1: %d", len(a.Files()))
    42  	}
    43  }