本文整理汇总了Golang中github.com/juju/juju/provider/azure/internal/azuretesting.NewSenderWithValue函数的典型用法代码示例。如果您正苦于以下问题:Golang NewSenderWithValue函数的具体用法?Golang NewSenderWithValue怎么用?Golang NewSenderWithValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewSenderWithValue函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getInstances
func (s *instanceSuite) getInstances(c *gc.C, ids ...instance.Id) []instance.Instance {
nicsSender := azuretesting.NewSenderWithValue(&network.InterfaceListResult{
Value: &s.networkInterfaces,
})
nicsSender.PathPattern = ".*/networkInterfaces"
vmsSender := azuretesting.NewSenderWithValue(&compute.VirtualMachineListResult{
Value: &s.virtualMachines,
})
vmsSender.PathPattern = ".*/virtualMachines"
pipsSender := azuretesting.NewSenderWithValue(&network.PublicIPAddressListResult{
Value: &s.publicIPAddresses,
})
pipsSender.PathPattern = ".*/publicIPAddresses"
s.sender = azuretesting.Senders{nicsSender, vmsSender, pipsSender}
instances, err := s.env.Instances(ids)
c.Assert(err, jc.ErrorIsNil)
s.sender = azuretesting.Senders{}
s.requests = nil
return instances
}
开发者ID:imoapps,项目名称:juju,代码行数:25,代码来源:instance_test.go
示例2: getInstancesSender
func (s *instanceSuite) getInstancesSender() azuretesting.Senders {
deploymentsSender := azuretesting.NewSenderWithValue(&resources.DeploymentListResult{
Value: &s.deployments,
})
deploymentsSender.PathPattern = ".*/deployments"
nicsSender := azuretesting.NewSenderWithValue(&network.InterfaceListResult{
Value: &s.networkInterfaces,
})
nicsSender.PathPattern = ".*/networkInterfaces"
pipsSender := azuretesting.NewSenderWithValue(&network.PublicIPAddressListResult{
Value: &s.publicIPAddresses,
})
pipsSender.PathPattern = ".*/publicIPAddresses"
return azuretesting.Senders{deploymentsSender, nicsSender, pipsSender}
}
开发者ID:bac,项目名称:juju,代码行数:15,代码来源:instance_test.go
示例3: deviceCodeSender
func deviceCodeSender() autorest.Sender {
return azuretesting.NewSenderWithValue(azure.DeviceCode{
DeviceCode: to.StringPtr("device-code"),
Interval: to.Int64Ptr(1), // 1 second between polls
Message: to.StringPtr("open your browser, etc."),
})
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:interactive_test.go
示例4: passwordCredentialsListSender
func passwordCredentialsListSender() autorest.Sender {
return azuretesting.NewSenderWithValue(ad.PasswordCredentialsListResult{
Value: []ad.PasswordCredential{{
KeyId: "password-credential-key-id",
}},
})
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:interactive_test.go
示例5: servicePrincipalListSender
func servicePrincipalListSender() autorest.Sender {
return azuretesting.NewSenderWithValue(ad.ServicePrincipalListResult{
Value: []ad.ServicePrincipal{{
ApplicationID: "cbb548f1-5039-4836-af0b-727e8571f6a9",
ObjectID: "sp-object-id",
}},
})
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:interactive_test.go
示例6: tokenRefreshSender
func tokenRefreshSender() *azuretesting.MockSender {
tokenRefreshSender := azuretesting.NewSenderWithValue(&autorestazure.Token{
AccessToken: "access-token",
ExpiresOn: fmt.Sprint(time.Now().Add(time.Hour).Unix()),
Type: "Bearer",
})
tokenRefreshSender.PathPattern = ".*/oauth2/token"
return tokenRefreshSender
}
开发者ID:bac,项目名称:juju,代码行数:9,代码来源:environ_test.go
示例7: networkSecurityGroupSender
func networkSecurityGroupSender(rules []network.SecurityRule) *azuretesting.MockSender {
nsgSender := azuretesting.NewSenderWithValue(&network.SecurityGroup{
Properties: &network.SecurityGroupPropertiesFormat{
SecurityRules: &rules,
},
})
nsgSender.PathPattern = ".*/networkSecurityGroups/juju-internal"
return nsgSender
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:instance_test.go
示例8: roleDefinitionListSender
func roleDefinitionListSender() autorest.Sender {
roleDefinitions := []authorization.RoleDefinition{{
ID: to.StringPtr("owner-role-id"),
Name: to.StringPtr("Owner"),
}}
return azuretesting.NewSenderWithValue(authorization.RoleDefinitionListResult{
Value: &roleDefinitions,
})
}
开发者ID:bac,项目名称:juju,代码行数:9,代码来源:interactive_test.go
示例9: accountKeysSender
func (s *storageSuite) accountKeysSender() *azuretesting.MockSender {
keys := []armstorage.AccountKey{{
KeyName: to.StringPtr(fakeStorageAccountKey + "-name"),
Value: to.StringPtr(fakeStorageAccountKey),
Permissions: armstorage.FULL,
}, {
KeyName: to.StringPtr("key2-name"),
Value: to.StringPtr("key2"),
Permissions: armstorage.FULL,
}}
result := armstorage.AccountListKeysResult{Keys: &keys}
keysSender := azuretesting.NewSenderWithValue(&result)
keysSender.PathPattern = ".*/storageAccounts/.*/listKeys"
return keysSender
}
开发者ID:bac,项目名称:juju,代码行数:15,代码来源:storage_test.go
示例10: accountSender
func (s *storageSuite) accountSender() *azuretesting.MockSender {
envTags := map[string]*string{
"juju-model-uuid": to.StringPtr(testing.ModelTag.Id()),
}
account := armstorage.Account{
Name: to.StringPtr(storageAccountName),
Type: to.StringPtr("Standard_LRS"),
Tags: &envTags,
Properties: &armstorage.AccountProperties{
PrimaryEndpoints: &armstorage.Endpoints{
Blob: to.StringPtr(fmt.Sprintf("https://%s.blob.storage.azurestack.local/", storageAccountName)),
},
},
}
accountSender := azuretesting.NewSenderWithValue(account)
accountSender.PathPattern = ".*/storageAccounts/" + storageAccountName + ".*"
return accountSender
}
开发者ID:bac,项目名称:juju,代码行数:18,代码来源:storage_test.go
示例11: makeSender
func (s *environSuite) makeSender(pattern string, v interface{}) *azuretesting.MockSender {
sender := azuretesting.NewSenderWithValue(v)
sender.PathPattern = pattern
return sender
}
开发者ID:bac,项目名称:juju,代码行数:5,代码来源:environ_test.go
示例12: createServicePrincipalSender
func createServicePrincipalSender() autorest.Sender {
return azuretesting.NewSenderWithValue(ad.ServicePrincipal{
ApplicationID: "cbb548f1-5039-4836-af0b-727e8571f6a9",
ObjectID: "sp-object-id",
})
}
开发者ID:bac,项目名称:juju,代码行数:6,代码来源:interactive_test.go
示例13: currentUserSender
func currentUserSender() autorest.Sender {
return azuretesting.NewSenderWithValue(ad.AADObject{
DisplayName: "Foo Bar",
})
}
开发者ID:bac,项目名称:juju,代码行数:5,代码来源:interactive_test.go
示例14: tokenSender
func tokenSender() autorest.Sender {
return azuretesting.NewSenderWithValue(azure.Token{
RefreshToken: "refresh-token",
ExpiresOn: fmt.Sprint(time.Now().Add(time.Hour).Unix()),
})
}
开发者ID:bac,项目名称:juju,代码行数:6,代码来源:interactive_test.go
示例15: roleAssignmentSender
func roleAssignmentSender() autorest.Sender {
return azuretesting.NewSenderWithValue(authorization.RoleAssignment{})
}
开发者ID:bac,项目名称:juju,代码行数:3,代码来源:interactive_test.go
示例16: TestDetachVolumes
func (s *storageSuite) TestDetachVolumes(c *gc.C) {
// machine-0 has a three data disks: volume-0, volume-1 and volume-2
machine0DataDisks := []compute.DataDisk{{
Lun: to.IntPtr(0),
Name: to.StringPtr("volume-0"),
Vhd: &compute.VirtualHardDisk{
URI: to.StringPtr(fmt.Sprintf(
"https://%s.blob.core.windows.net/datavhds/volume-0.vhd",
fakeStorageAccount,
)),
},
}, {
Lun: to.IntPtr(1),
Name: to.StringPtr("volume-1"),
Vhd: &compute.VirtualHardDisk{
URI: to.StringPtr(fmt.Sprintf(
"https://%s.blob.core.windows.net/datavhds/volume-1.vhd",
fakeStorageAccount,
)),
},
}, {
Lun: to.IntPtr(2),
Name: to.StringPtr("volume-2"),
Vhd: &compute.VirtualHardDisk{
URI: to.StringPtr(fmt.Sprintf(
"https://%s.blob.core.windows.net/datavhds/volume-2.vhd",
fakeStorageAccount,
)),
},
}}
makeParams := func(volume, machine string) storage.VolumeAttachmentParams {
return storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
Provider: "azure",
Machine: names.NewMachineTag(machine),
InstanceId: instance.Id("machine-" + machine),
},
Volume: names.NewVolumeTag(volume),
VolumeId: "volume-" + volume,
}
}
params := []storage.VolumeAttachmentParams{
makeParams("1", "0"),
makeParams("1", "0"),
makeParams("42", "1"),
makeParams("2", "42"),
}
virtualMachines := []compute.VirtualMachine{{
Name: to.StringPtr("machine-0"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{DataDisks: &machine0DataDisks},
},
}, {
Name: to.StringPtr("machine-1"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{},
},
}}
// There should be a couple of API calls to list instances,
// and one update per modified instance.
nics := []network.Interface{
makeNetworkInterface("nic-0", "machine-0"),
makeNetworkInterface("nic-1", "machine-1"),
}
nicsSender := azuretesting.NewSenderWithValue(network.InterfaceListResult{
Value: &nics,
})
nicsSender.PathPattern = `.*/Microsoft\.Network/networkInterfaces`
virtualMachinesSender := azuretesting.NewSenderWithValue(compute.VirtualMachineListResult{
Value: &virtualMachines,
})
virtualMachinesSender.PathPattern = `.*/Microsoft\.Compute/virtualMachines`
updateVirtualMachine0Sender := azuretesting.NewSenderWithValue(&compute.VirtualMachine{})
updateVirtualMachine0Sender.PathPattern = `.*/Microsoft\.Compute/virtualMachines/machine-0`
volumeSource := s.volumeSource(c)
s.sender = azuretesting.Senders{
nicsSender,
virtualMachinesSender,
updateVirtualMachine0Sender,
}
results, err := volumeSource.DetachVolumes(params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results, gc.HasLen, len(params))
c.Check(results[0], jc.ErrorIsNil)
c.Check(results[1], jc.ErrorIsNil)
c.Check(results[2], jc.ErrorIsNil)
c.Check(results[3], gc.ErrorMatches, "instance machine-42 not found")
// Validate HTTP request bodies.
c.Assert(s.requests, gc.HasLen, 3)
c.Assert(s.requests[0].Method, gc.Equals, "GET") // list NICs
c.Assert(s.requests[1].Method, gc.Equals, "GET") // list virtual machines
c.Assert(s.requests[2].Method, gc.Equals, "PUT") // update machine-0
machine0DataDisks = []compute.DataDisk{
//.........这里部分代码省略.........
开发者ID:exekias,项目名称:juju,代码行数:101,代码来源:storage_test.go
示例17: TestCreateVolumes
func (s *storageSuite) TestCreateVolumes(c *gc.C) {
// machine-1 has a single data disk with LUN 0.
machine1DataDisks := []compute.DataDisk{{Lun: to.IntPtr(0)}}
// machine-2 has 32 data disks; no LUNs free.
machine2DataDisks := make([]compute.DataDisk, 32)
for i := range machine2DataDisks {
machine2DataDisks[i].Lun = to.IntPtr(i)
}
// volume-0 and volume-2 are attached to machine-0
// volume-1 is attached to machine-1
// volume-3 is attached to machine-42, but machine-42 is missing
// volume-42 is attached to machine-2, but machine-2 has no free LUNs
makeVolumeParams := func(volume, machine string, size uint64) storage.VolumeParams {
return storage.VolumeParams{
Tag: names.NewVolumeTag(volume),
Size: size,
Provider: "azure",
Attachment: &storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
Provider: "azure",
Machine: names.NewMachineTag(machine),
InstanceId: instance.Id("machine-" + machine),
},
Volume: names.NewVolumeTag(volume),
},
}
}
params := []storage.VolumeParams{
makeVolumeParams("0", "0", 1),
makeVolumeParams("1", "1", 1025),
makeVolumeParams("2", "0", 1024),
makeVolumeParams("3", "42", 40),
makeVolumeParams("42", "2", 50),
}
virtualMachines := []compute.VirtualMachine{{
Name: to.StringPtr("machine-0"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{},
},
}, {
Name: to.StringPtr("machine-1"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{DataDisks: &machine1DataDisks},
},
}, {
Name: to.StringPtr("machine-2"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{DataDisks: &machine2DataDisks},
},
}}
// There should be a couple of API calls to list instances,
// and one update per modified instance.
nics := []network.Interface{
makeNetworkInterface("nic-0", "machine-0"),
makeNetworkInterface("nic-1", "machine-1"),
makeNetworkInterface("nic-2", "machine-2"),
}
nicsSender := azuretesting.NewSenderWithValue(network.InterfaceListResult{
Value: &nics,
})
nicsSender.PathPattern = `.*/Microsoft\.Network/networkInterfaces`
virtualMachinesSender := azuretesting.NewSenderWithValue(compute.VirtualMachineListResult{
Value: &virtualMachines,
})
virtualMachinesSender.PathPattern = `.*/Microsoft\.Compute/virtualMachines`
updateVirtualMachine0Sender := azuretesting.NewSenderWithValue(&compute.VirtualMachine{})
updateVirtualMachine0Sender.PathPattern = `.*/Microsoft\.Compute/virtualMachines/machine-0`
updateVirtualMachine1Sender := azuretesting.NewSenderWithValue(&compute.VirtualMachine{})
updateVirtualMachine1Sender.PathPattern = `.*/Microsoft\.Compute/virtualMachines/machine-1`
volumeSource := s.volumeSource(c)
s.sender = azuretesting.Senders{
nicsSender,
virtualMachinesSender,
updateVirtualMachine0Sender,
updateVirtualMachine1Sender,
}
results, err := volumeSource.CreateVolumes(params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results, gc.HasLen, len(params))
c.Check(results[0].Error, jc.ErrorIsNil)
c.Check(results[1].Error, jc.ErrorIsNil)
c.Check(results[2].Error, jc.ErrorIsNil)
c.Check(results[3].Error, gc.ErrorMatches, "instance machine-42 not found")
c.Check(results[4].Error, gc.ErrorMatches, "choosing LUN: all LUNs are in use")
// Validate HTTP request bodies.
c.Assert(s.requests, gc.HasLen, 4)
c.Assert(s.requests[0].Method, gc.Equals, "GET") // list NICs
c.Assert(s.requests[1].Method, gc.Equals, "GET") // list virtual machines
c.Assert(s.requests[2].Method, gc.Equals, "PUT") // update machine-0
c.Assert(s.requests[3].Method, gc.Equals, "PUT") // update machine-1
machine0DataDisks := []compute.DataDisk{{
Lun: to.IntPtr(0),
DiskSizeGB: to.IntPtr(1),
//.........这里部分代码省略.........
开发者ID:exekias,项目名称:juju,代码行数:101,代码来源:storage_test.go
示例18: TestAttachVolumes
func (s *storageSuite) TestAttachVolumes(c *gc.C) {
// machine-1 has a single data disk with LUN 0.
machine1DataDisks := []compute.DataDisk{{
Lun: to.Int32Ptr(0),
Name: to.StringPtr("volume-1"),
Vhd: &compute.VirtualHardDisk{
URI: to.StringPtr(fmt.Sprintf(
"https://%s.blob.storage.azurestack.local/datavhds/volume-1.vhd",
storageAccountName,
)),
},
}}
// machine-2 has 32 data disks; no LUNs free.
machine2DataDisks := make([]compute.DataDisk, 32)
for i := range machine2DataDisks {
machine2DataDisks[i].Lun = to.Int32Ptr(int32(i))
machine2DataDisks[i].Name = to.StringPtr(fmt.Sprintf("volume-%d", i))
machine2DataDisks[i].Vhd = &compute.VirtualHardDisk{
URI: to.StringPtr(fmt.Sprintf(
"https://%s.blob.storage.azurestack.local/datavhds/volume-%d.vhd",
storageAccountName, i,
)),
}
}
// volume-0 and volume-2 are attached to machine-0
// volume-1 is attached to machine-1
// volume-3 is attached to machine-42, but machine-42 is missing
// volume-42 is attached to machine-2, but machine-2 has no free LUNs
makeParams := func(volume, machine string, size uint64) storage.VolumeAttachmentParams {
return storage.VolumeAttachmentParams{
AttachmentParams: storage.AttachmentParams{
Provider: "azure",
Machine: names.NewMachineTag(machine),
InstanceId: instance.Id("machine-" + machine),
},
Volume: names.NewVolumeTag(volume),
VolumeId: "volume-" + volume,
}
}
params := []storage.VolumeAttachmentParams{
makeParams("0", "0", 1),
makeParams("1", "1", 1025),
makeParams("2", "0", 1024),
makeParams("3", "42", 40),
makeParams("42", "2", 50),
}
virtualMachines := []compute.VirtualMachine{{
Name: to.StringPtr("machine-0"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{},
},
}, {
Name: to.StringPtr("machine-1"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{DataDisks: &machine1DataDisks},
},
}, {
Name: to.StringPtr("machine-2"),
Properties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{DataDisks: &machine2DataDisks},
},
}}
// There should be a one API calls to list VMs, and one update per modified instance.
virtualMachinesSender := azuretesting.NewSenderWithValue(compute.VirtualMachineListResult{
Value: &virtualMachines,
})
virtualMachinesSender.PathPattern = `.*/Microsoft\.Compute/virtualMachines`
updateVirtualMachine0Sender := azuretesting.NewSenderWithValue(&compute.VirtualMachine{})
updateVirtualMachine0Sender.PathPattern = `.*/Microsoft\.Compute/virtualMachines/machine-0`
volumeSource := s.volumeSource(c)
s.sender = azuretesting.Senders{
virtualMachinesSender,
s.accountSender(),
updateVirtualMachine0Sender,
}
results, err := volumeSource.AttachVolumes(params)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results, gc.HasLen, len(params))
c.Check(results[0].Error, jc.ErrorIsNil)
c.Check(results[1].Error, jc.ErrorIsNil)
c.Check(results[2].Error, jc.ErrorIsNil)
c.Check(results[3].Error, gc.ErrorMatches, "instance machine-42 not found")
c.Check(results[4].Error, gc.ErrorMatches, "choosing LUN: all LUNs are in use")
// Validate HTTP request bodies.
c.Assert(s.requests, gc.HasLen, 3)
c.Assert(s.requests[0].Method, gc.Equals, "GET") // list virtual machines
c.Assert(s.requests[1].Method, gc.Equals, "GET") // list storage accounts
c.Assert(s.requests[2].Method, gc.Equals, "PUT") // update machine-0
machine0DataDisks := []compute.DataDisk{{
Lun: to.Int32Ptr(0),
Name: to.StringPtr("volume-0"),
Vhd: &compute.VirtualHardDisk{URI: to.StringPtr(fmt.Sprintf(
"https://%s.blob.storage.azurestack.local/datavhds/volume-0.vhd",
//.........这里部分代码省略.........
开发者ID:bac,项目名称:juju,代码行数:101,代码来源:storage_test.go
注:本文中的github.com/juju/juju/provider/azure/internal/azuretesting.NewSenderWithValue函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论