This commit is contained in:
Paul Meyer 2019-10-03 04:23:37 +00:00
parent 0694f2635b
commit 716f19a457
3 changed files with 10 additions and 11 deletions

View File

@ -20,7 +20,7 @@ func TestBuilder_Prepare_DiskAsInput(t *testing.T) {
t.Error("Expected the returned error to be of type packer.MultiError") t.Error("Expected the returned error to be of type packer.MultiError")
} }
for _, err := range errs.Errors { for _, err := range errs.Errors {
if matched, _:=regexp.MatchString(`(^|\W)source\W`,err.Error()); matched { if matched, _ := regexp.MatchString(`(^|\W)source\W`, err.Error()); matched {
t.Errorf("Did not expect an error about the 'source' field, but found %q", err) t.Errorf("Did not expect an error about the 'source' field, but found %q", err)
} }
} }

View File

@ -17,11 +17,11 @@ type MetadataClientAPI interface {
GetComputeInfo() (*ComputeInfo, error) GetComputeInfo() (*ComputeInfo, error)
} }
type ComputeInfo struct{ type ComputeInfo struct {
Name string Name string
ResourceGroupName string ResourceGroupName string
SubscriptionID string SubscriptionID string
Location string Location string
} }
// metadataClient implements MetadataClient // metadataClient implements MetadataClient
@ -65,7 +65,7 @@ func (client metadataClient) GetComputeInfo() (*ComputeInfo, error) {
return &vminfo.ComputeInfo, nil return &vminfo.ComputeInfo, nil
} }
func(ci ComputeInfo) ResourceID() string{ func (ci ComputeInfo) ResourceID() string {
return fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/%s", return fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachines/%s",
ci.SubscriptionID, ci.SubscriptionID,
ci.ResourceGroupName, ci.ResourceGroupName,

View File

@ -1,31 +1,30 @@
package client package client
import ( import (
"errors"
"net/http"
"os" "os"
"testing" "testing"
"net/http"
"errors"
"github.com/Azure/go-autorest/autorest/azure/auth" "github.com/Azure/go-autorest/autorest/azure/auth"
) )
func GetTestClientSet(t *testing.T) (AzureClientSet, error) { func GetTestClientSet(t *testing.T) (AzureClientSet, error) {
if (os.Getenv("AZURE_INTEGRATION_TEST") == "") { if os.Getenv("AZURE_INTEGRATION_TEST") == "" {
t.Skip("AZURE_INTEGRATION_TEST not set") t.Skip("AZURE_INTEGRATION_TEST not set")
} else { } else {
a, err := auth.NewAuthorizerFromEnvironment() a, err := auth.NewAuthorizerFromEnvironment()
if err == nil { if err == nil {
cli := azureClientSet{} cli := azureClientSet{}
cli.authorizer = a cli.authorizer = a
cli.subscriptionID = os.Getenv("AZURE_SUBSCRIPTION_ID") cli.subscriptionID = os.Getenv("AZURE_SUBSCRIPTION_ID")
cli.PollingDelay = 0 cli.PollingDelay = 0
cli.sender = http.DefaultClient cli.sender = http.DefaultClient
return cli, nil return cli, nil
} else { } else {
t.Skipf("Could not create Azure client: %v", err) t.Skipf("Could not create Azure client: %v", err)
} }
} }
return nil, errors.New("Couldn't create client set") return nil, errors.New("Couldn't create client set")
} }