Merge pull request #6822 from hashicorp/fix_6774

Fix 6774
This commit is contained in:
Megan Marsh 2018-10-10 13:25:58 -07:00 committed by GitHub
commit cdc6c57b31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -133,7 +133,10 @@ func (*Artifact) Files() []string {
}
func (a *Artifact) Id() string {
return a.OSDiskUri
if a.OSDiskUri != "" {
return a.OSDiskUri
}
return a.ManagedImageId
}
func (a *Artifact) State(name string) interface{} {

View File

@ -10,7 +10,7 @@ func getFakeSasUrl(name string) string {
return fmt.Sprintf("SAS-%s", name)
}
func TestArtifactId(t *testing.T) {
func TestArtifactIdVHD(t *testing.T) {
template := CaptureTemplate{
Resources: []CaptureResources{
{
@ -41,6 +41,20 @@ func TestArtifactId(t *testing.T) {
}
}
func TestArtifactIDManagedImage(t *testing.T) {
artifact, err := NewManagedImageArtifact("Linux", "fakeResourceGroup", "fakeName", "fakeLocation", "fakeID")
if err != nil {
t.Fatalf("err=%s", err)
}
expected := "fakeID"
result := artifact.Id()
if result != expected {
t.Fatalf("bad: %s", result)
}
}
func TestArtifactString(t *testing.T) {
template := CaptureTemplate{
Resources: []CaptureResources{