Update the network sdk and add more validations
This commit is contained in:
@@ -1,22 +1,16 @@
|
||||
package network
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-08-01/network"
|
||||
)
|
||||
|
||||
func TestCreateGetSubnet(t *testing.T) {
|
||||
c := newTestClient(t)
|
||||
|
||||
subnet := &Subnet{
|
||||
Name: t.Name(),
|
||||
Properties: &SubnetProperties{
|
||||
AddressPrefix: "10.0.0.0/24",
|
||||
Delegations: []Delegation{
|
||||
{Name: "aciDelegation", Properties: DelegationProperties{
|
||||
ServiceName: "Microsoft.ContainerInstance/containerGroups",
|
||||
Actions: []string{"Microsoft.Network/virtualNetworks/subnets/action"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
}
|
||||
subnet := NewSubnetWithContainerInstanceDelegation(t.Name(), "10.0.0.0/24")
|
||||
|
||||
ensureVnet(t, t.Name())
|
||||
|
||||
s1, err := c.CreateOrUpdateSubnet(resourceGroup, t.Name(), subnet)
|
||||
@@ -26,25 +20,25 @@ func TestCreateGetSubnet(t *testing.T) {
|
||||
if s1 == nil {
|
||||
t.Fatal("create subnet should return subnet")
|
||||
}
|
||||
if s1.ID == "" {
|
||||
if s1.ID == nil || *s1.ID == "" {
|
||||
t.Fatal("create subnet should return subnet.ID")
|
||||
}
|
||||
|
||||
var s2 *Subnet
|
||||
s2, err = c.GetSubnet(resourceGroup, t.Name(), subnet.Name)
|
||||
var s2 *network.Subnet
|
||||
s2, err = c.GetSubnet(resourceGroup, t.Name(), *subnet.Name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if s2.Name != subnet.Name {
|
||||
if *s2.Name != *subnet.Name {
|
||||
t.Fatal("got unexpected subnet")
|
||||
}
|
||||
if s2.Properties.AddressPrefix != subnet.Properties.AddressPrefix {
|
||||
t.Fatalf("got unexpected address prefix: %s", s2.Properties.AddressPrefix)
|
||||
if *s2.SubnetPropertiesFormat.AddressPrefix != *subnet.SubnetPropertiesFormat.AddressPrefix {
|
||||
t.Fatalf("got unexpected address prefix: %s", *s2.SubnetPropertiesFormat.AddressPrefix)
|
||||
}
|
||||
if len(s2.Properties.Delegations) != 1 {
|
||||
t.Fatalf("got unexpected delgations: %v", s2.Properties.Delegations)
|
||||
if len(*s2.SubnetPropertiesFormat.Delegations) != 1 {
|
||||
t.Fatalf("got unexpected delgations: %v", *s2.SubnetPropertiesFormat.Delegations)
|
||||
}
|
||||
if s2.Properties.Delegations[0].Name != subnet.Properties.Delegations[0].Name {
|
||||
t.Fatalf("got unexpected delegation: %v", s2.Properties.Delegations[0])
|
||||
if *(*s2.SubnetPropertiesFormat.Delegations)[0].Name != *(*subnet.SubnetPropertiesFormat.Delegations)[0].Name {
|
||||
t.Fatalf("got unexpected delegation: %v", (*s2.SubnetPropertiesFormat.Delegations)[0])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user