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")
}
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)
}
}

View File

@ -17,11 +17,11 @@ type MetadataClientAPI interface {
GetComputeInfo() (*ComputeInfo, error)
}
type ComputeInfo struct{
type ComputeInfo struct {
Name string
ResourceGroupName string
SubscriptionID string
Location string
Location string
}
// metadataClient implements MetadataClient
@ -65,7 +65,7 @@ func (client metadataClient) GetComputeInfo() (*ComputeInfo, error) {
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",
ci.SubscriptionID,
ci.ResourceGroupName,

View File

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