github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/builder/azure/arm/tempname_test.go (about) 1 package arm 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestTempNameShouldCreatePrefixedRandomNames(t *testing.T) { 9 tempName := NewTempName() 10 11 if strings.Index(tempName.ComputeName, "pkrvm") != 0 { 12 t.Errorf("Expected ComputeName to begin with 'pkrvm', but got '%s'!", tempName.ComputeName) 13 } 14 15 if strings.Index(tempName.DeploymentName, "pkrdp") != 0 { 16 t.Errorf("Expected ComputeName to begin with 'pkrdp', but got '%s'!", tempName.ComputeName) 17 } 18 19 if strings.Index(tempName.OSDiskName, "pkros") != 0 { 20 t.Errorf("Expected OSDiskName to begin with 'pkros', but got '%s'!", tempName.OSDiskName) 21 } 22 23 if strings.Index(tempName.ResourceGroupName, "packer-Resource-Group-") != 0 { 24 t.Errorf("Expected ResourceGroupName to begin with 'packer-Resource-Group-', but got '%s'!", tempName.ResourceGroupName) 25 } 26 } 27 28 func TestTempNameShouldHaveSameSuffix(t *testing.T) { 29 tempName := NewTempName() 30 suffix := tempName.ComputeName[5:] 31 32 if strings.HasSuffix(tempName.DeploymentName, suffix) != true { 33 t.Errorf("Expected DeploymentName to end with '%s', but the value is '%s'!", suffix, tempName.DeploymentName) 34 } 35 36 if strings.HasSuffix(tempName.OSDiskName, suffix) != true { 37 t.Errorf("Expected OSDiskName to end with '%s', but the value is '%s'!", suffix, tempName.OSDiskName) 38 } 39 40 if strings.HasSuffix(tempName.ResourceGroupName, suffix) != true { 41 t.Errorf("Expected ResourceGroupName to end with '%s', but the value is '%s'!", suffix, tempName.ResourceGroupName) 42 } 43 44 }