Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: graysonwu <[email protected]>
  • Loading branch information
GraysonWu committed Feb 14, 2024
1 parent 68b2429 commit aa34f79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 deletions nsxt/data_source_nsxt_policy_gateway_interface_realization_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func dataSourceNsxtPolicyGatewayInterfaceRealizationInfo() *schema.Resource {
Type: schema.TypeInt,
Description: "Realization timeout in seconds",
Optional: true,
Default: 1200,
Default: 600,
ValidateFunc: validation.IntAtLeast(1),
},
"delay": {
Type: schema.TypeInt,
Description: "Initial delay to start realization checks in seconds",
Optional: true,
Default: 1,
Default: 5,
ValidateFunc: validation.IntAtLeast(0),
},
"state": {
Expand Down Expand Up @@ -118,6 +118,14 @@ func dataSourceNsxtPolicyGatewayInterfaceRealizationInfoRead(d *schema.ResourceD
}
}

if id == "" && displayName == "" && len(result.Results) > 0 {
// If neither ID nor displayName is provided and there is no entity contains IpAddresses,
// return the first one.
obj := result.Results[0]
setGatewayInterfaceRealizationInfoInSchema(obj, d)
return result, *obj.State, nil
}

if len(perfectMatch) > 1 {
return result, "", fmt.Errorf("Found multiple gateway interfaces with name '%s'", displayName)
}
Expand Down
8 changes: 8 additions & 0 deletions nsxt/resource_nsxt_policy_tier0_gateway_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,19 @@ func testAccNsxtPolicyTier0InterfaceRealizationTemplate() string {
data "nsxt_policy_realization_info" "realization_info" {
path = nsxt_policy_tier0_gateway_interface.test.path
site_path = data.nsxt_policy_site.test.path
}
data "nsxt_policy_gateway_interface_realization_info" "gw_realization_info" {
gateway_path = nsxt_policy_tier0_gateway_interface.test.path
}`
}
return `
data "nsxt_policy_realization_info" "realization_info" {
path = nsxt_policy_tier0_gateway_interface.test.path
}
data "nsxt_policy_gateway_interface_realization_info" "gw_realization_info" {
gateway_path = nsxt_policy_tier0_gateway_interface.test.path
}`
}

Expand Down

0 comments on commit aa34f79

Please sign in to comment.