Skip to content

Commit

Permalink
Merge pull request #1049 from ksamoray/policy_project_411
Browse files Browse the repository at this point in the history
Update nsxt_policy_project to NSX v4.1.1 behavior
  • Loading branch information
ksamoray authored Dec 3, 2023
2 parents 5d6057f + e455950 commit 92dc814
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions nsxt/resource_nsxt_policy_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func resourceNsxtPolicyProject() *schema.Resource {
},
},
Optional: true,
Computed: true,
},
"tier0_gateway_paths": {
Type: schema.TypeList,
Expand Down
26 changes: 23 additions & 3 deletions nsxt/resource_nsxt_policy_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ var accTestPolicyProjectUpdateAttributes = map[string]string{
"short_id": shortID,
}

func getExpectedSiteInfoCount(t *testing.T) string {
if nsxVersion == "" {
connector, err := testAccGetPolicyConnector()
if err != nil {
t.Errorf("Failed to get policy connector")
return "0"
}

err = initNSXVersion(connector)
if err != nil {
t.Errorf("Failed to retrieve NSX version")
return "0"
}
}
if nsxVersionHigherOrEqual("4.1.1") {
return "1"
}
return "0"
}

func TestAccResourceNsxtPolicyProject_basic(t *testing.T) {
testResourceName := "nsxt_policy_project.test"

Expand All @@ -47,7 +67,7 @@ func TestAccResourceNsxtPolicyProject_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "description", accTestPolicyProjectCreateAttributes["description"]),
resource.TestCheckResourceAttr(testResourceName, "short_id", accTestPolicyProjectCreateAttributes["short_id"]),
//TODO: add site info validation
resource.TestCheckResourceAttr(testResourceName, "site_info.#", "0"),
resource.TestCheckResourceAttr(testResourceName, "site_info.#", getExpectedSiteInfoCount(t)),
resource.TestCheckResourceAttr(testResourceName, "tier0_gateway_paths.#", "1"),

resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"),
Expand All @@ -63,7 +83,7 @@ func TestAccResourceNsxtPolicyProject_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "display_name", accTestPolicyProjectUpdateAttributes["display_name"]),
resource.TestCheckResourceAttr(testResourceName, "description", accTestPolicyProjectUpdateAttributes["description"]),
resource.TestCheckResourceAttr(testResourceName, "short_id", accTestPolicyProjectCreateAttributes["short_id"]),
resource.TestCheckResourceAttr(testResourceName, "site_info.#", "0"),
resource.TestCheckResourceAttr(testResourceName, "site_info.#", getExpectedSiteInfoCount(t)),
resource.TestCheckResourceAttr(testResourceName, "tier0_gateway_paths.#", "1"),

resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"),
Expand All @@ -79,7 +99,7 @@ func TestAccResourceNsxtPolicyProject_basic(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "display_name", accTestPolicyProjectUpdateAttributes["display_name"]),
resource.TestCheckResourceAttr(testResourceName, "description", accTestPolicyProjectUpdateAttributes["description"]),
resource.TestCheckResourceAttr(testResourceName, "short_id", accTestPolicyProjectCreateAttributes["short_id"]),
resource.TestCheckResourceAttr(testResourceName, "site_info.#", "0"),
resource.TestCheckResourceAttr(testResourceName, "site_info.#", getExpectedSiteInfoCount(t)),
resource.TestCheckResourceAttr(testResourceName, "tier0_gateway_paths.#", "0"),

resource.TestCheckResourceAttrSet(testResourceName, "nsx_id"),
Expand Down

0 comments on commit 92dc814

Please sign in to comment.