-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Compute Manager data source #976
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ import ( | |
) | ||
|
||
func TestAccDataSourceNsxtComputeManager_basic(t *testing.T) { | ||
ComputeManagerName := getComputeManagerName() | ||
testResourceName := "data.nsxt_edge_cluster.test" | ||
computeManagerName := getComputeManagerName() | ||
testResourceName := "data.nsxt_compute_manager.test" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
|
@@ -23,11 +23,32 @@ func TestAccDataSourceNsxtComputeManager_basic(t *testing.T) { | |
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccNSXComputeManagerReadTemplate(ComputeManagerName), | ||
Config: testAccNSXComputeManagerReadTemplate(computeManagerName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(testResourceName, "display_name", ComputeManagerName), | ||
resource.TestCheckResourceAttr(testResourceName, "display_name", computeManagerName), | ||
resource.TestCheckResourceAttrSet(testResourceName, "id"), | ||
resource.TestCheckResourceAttrSet(testResourceName, "server"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccDataSourceNsxtComputeManager_single(t *testing.T) { | ||
testResourceName := "data.nsxt_compute_manager.test" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccOnlyLocalManager(t) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure whether we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. I think that I added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
testAccPreCheck(t) | ||
}, | ||
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccNSXComputeManagerSingleReadTemplate(), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(testResourceName, "display_name"), | ||
resource.TestCheckResourceAttrSet(testResourceName, "id"), | ||
resource.TestCheckResourceAttrSet(testResourceName, "description"), | ||
resource.TestCheckResourceAttrSet(testResourceName, "server"), | ||
), | ||
}, | ||
|
@@ -41,3 +62,9 @@ data "nsxt_compute_manager" "test" { | |
display_name = "%s" | ||
}`, name) | ||
} | ||
|
||
func testAccNSXComputeManagerSingleReadTemplate() string { | ||
return ` | ||
data "nsxt_compute_manager" "test" { | ||
}` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if there are multiple compute managers, an empty
display_name
will cause an error. I'm wondering if we should add a more informative err msg indicating empty display_name can only be used with single compute manager to reduce the confusion or change the behavior here to just grab the first compute manager or just treat it as a match all for prefixMatch. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should decide which manager to grab without further input from the user.
Failing the data source because multiple objects are matching is a behavior present in most data sources in the provider. Regarding error messages - perhaps we should unify these messages across all data sources for consistency?
I can add more info in the doc for the case of compute manager.