Skip to content

Commit

Permalink
add test cases; remove unnecessary test constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Oct 14, 2024
1 parent 3eb636b commit 4d99735
Showing 1 changed file with 66 additions and 5 deletions.
71 changes: 66 additions & 5 deletions apstra/resource_datacenter_virtual_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ func (o resourceDatacenterVirtualNetworkTemplateBinding) render() string {
}

func (o resourceDatacenterVirtualNetworkTemplateBinding) addTestChecks(t testing.TB, testChecks *testChecks) {
// testChecks.append(t, "TestCheckResourceAttrSet", "bindings."+o.leafId)
if o.vlanId != nil {
testChecks.append(t, "TestCheckResourceAttr", "bindings."+o.leafId+".vlan_id", strconv.Itoa(*o.vlanId))
testChecks.append(t, "TestCheckResourceAttr", "bindings."+o.leafId+".access_ids.#", strconv.Itoa(len(o.accessIds)))
for _, access := range o.accessIds {
testChecks.append(t, "TestCheckTypeSetElemAttr", "bindings."+o.leafId+".access_ids.*", access)
}
}
// todo more checks here
}

func TestAccDatacenterVirtualNetwork(t *testing.T) {
Expand Down Expand Up @@ -319,7 +317,6 @@ func TestAccDatacenterVirtualNetwork(t *testing.T) {
},
},
"vlan_with_binding_start_minimal": {
apiVersionConstraints: compatibility.VnEmptyBindingsOk,
steps: []testStep{
{
config: resourceDatacenterVirtualNetworkTemplate{
Expand Down Expand Up @@ -366,7 +363,6 @@ func TestAccDatacenterVirtualNetwork(t *testing.T) {
},
},
"vlan_with_binding_start_maximal": {
apiVersionConstraints: compatibility.VnEmptyBindingsOk,
steps: []testStep{
{
config: resourceDatacenterVirtualNetworkTemplate{
Expand Down Expand Up @@ -416,7 +412,6 @@ func TestAccDatacenterVirtualNetwork(t *testing.T) {
},
},
"vxlan_with_binding_start_minimal": {
apiVersionConstraints: compatibility.VnEmptyBindingsOk,
steps: []testStep{
{
config: resourceDatacenterVirtualNetworkTemplate{
Expand Down Expand Up @@ -473,6 +468,72 @@ func TestAccDatacenterVirtualNetwork(t *testing.T) {
},
},
},
"vxlan_with_binding_start_maximal": {
steps: []testStep{
{
config: resourceDatacenterVirtualNetworkTemplate{
blueprintId: bp.Id(),
name: acctest.RandString(6),
vnType: apstra.VnTypeVxlan.String(),
vni: nil,
routingZoneId: szId,
l3Mtu: nil,
bindings: []resourceDatacenterVirtualNetworkTemplateBinding{
{
leafId: nodesByLabel["l2_one_access_002_leaf1"],
vlanId: utils.ToPtr(711),
accessIds: []string{nodesByLabel["l2_one_access_002_access1"]},
},
{
leafId: nodesByLabel["l2_one_access_003_leaf1"],
vlanId: utils.ToPtr(712),
accessIds: []string{nodesByLabel["l2_one_access_003_access1"]},
},
{
leafId: nodesByLabel["l2_esi_acs_dual_001_leaf_pair1"],
vlanId: utils.ToPtr(713),
accessIds: []string{nodesByLabel["l2_esi_acs_dual_001_access_pair1"]},
},
},
},
},
{
config: resourceDatacenterVirtualNetworkTemplate{
blueprintId: bp.Id(),
name: acctest.RandString(6),
vnType: apstra.VnTypeVxlan.String(),
routingZoneId: szId,
bindings: []resourceDatacenterVirtualNetworkTemplateBinding{
{
leafId: nodesByLabel["l2_esi_acs_dual_002_leaf_pair1"],
},
},
},
},
{
config: resourceDatacenterVirtualNetworkTemplate{
blueprintId: bp.Id(),
name: acctest.RandString(6),
vnType: apstra.VnTypeVxlan.String(),
vni: nil,
routingZoneId: szId,
l3Mtu: nil,
bindings: []resourceDatacenterVirtualNetworkTemplateBinding{
{
leafId: nodesByLabel["l2_one_access_001_leaf1"],
vlanId: utils.ToPtr(731),
accessIds: []string{nodesByLabel["l2_one_access_001_access1"]},
},
{
leafId: nodesByLabel["l2_esi_acs_dual_002_leaf_pair1"],
vlanId: utils.ToPtr(733),
accessIds: []string{nodesByLabel["l2_esi_acs_dual_002_access_pair1"]},
},
},
},
},
},
},
}

resourceType := tfapstra.ResourceName(ctx, &tfapstra.ResourceDatacenterVirtualNetwork)
Expand Down

0 comments on commit 4d99735

Please sign in to comment.