github.com/angdraug/packer@v1.3.2/builder/digitalocean/artifact_test.go (about)

     1  package digitalocean
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/packer/packer"
     7  )
     8  
     9  func TestArtifact_Impl(t *testing.T) {
    10  	var raw interface{}
    11  	raw = &Artifact{}
    12  	if _, ok := raw.(packer.Artifact); !ok {
    13  		t.Fatalf("Artifact should be artifact")
    14  	}
    15  }
    16  
    17  func TestArtifactId(t *testing.T) {
    18  	a := &Artifact{"packer-foobar", 42, []string{"sfo", "tor1"}, nil}
    19  	expected := "sfo,tor1:42"
    20  
    21  	if a.Id() != expected {
    22  		t.Fatalf("artifact ID should match: %v", expected)
    23  	}
    24  }
    25  
    26  func TestArtifactIdWithoutMultipleRegions(t *testing.T) {
    27  	a := &Artifact{"packer-foobar", 42, []string{"sfo"}, nil}
    28  	expected := "sfo:42"
    29  
    30  	if a.Id() != expected {
    31  		t.Fatalf("artifact ID should match: %v", expected)
    32  	}
    33  }
    34  
    35  func TestArtifactString(t *testing.T) {
    36  	a := &Artifact{"packer-foobar", 42, []string{"sfo", "tor1"}, nil}
    37  	expected := "A snapshot was created: 'packer-foobar' (ID: 42) in regions 'sfo,tor1'"
    38  
    39  	if a.String() != expected {
    40  		t.Fatalf("artifact string should match: %v", expected)
    41  	}
    42  }
    43  
    44  func TestArtifactStringWithoutMultipleRegions(t *testing.T) {
    45  	a := &Artifact{"packer-foobar", 42, []string{"sfo"}, nil}
    46  	expected := "A snapshot was created: 'packer-foobar' (ID: 42) in regions 'sfo'"
    47  
    48  	if a.String() != expected {
    49  		t.Fatalf("artifact string should match: %v", expected)
    50  	}
    51  }