-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_log_analytics_saved_search
- update validation for azurerm_log_analytics_saved_search
#26701
azurerm_log_analytics_saved_search
- update validation for azurerm_log_analytics_saved_search
#26701
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 | ||||
---|---|---|---|---|---|---|
|
@@ -64,6 +64,35 @@ func TestAccLogAnalyticsSavedSearch_withTag(t *testing.T) { | |||||
}) | ||||||
} | ||||||
|
||||||
func TestAccLogAnalyticsSavedSearch_functionParameter(t *testing.T) { | ||||||
data := acceptance.BuildTestData(t, "azurerm_log_analytics_saved_search", "test") | ||||||
r := LogAnalyticsSavedSearchResource{} | ||||||
|
||||||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||||||
{ | ||||||
Config: r.function_parameter(data, "foo:(*)"), | ||||||
Check: acceptance.ComposeTestCheckFunc( | ||||||
check.That(data.ResourceName).ExistsInAzure(r), | ||||||
), | ||||||
}, | ||||||
data.ImportStep(), | ||||||
{ | ||||||
Config: r.function_parameter(data, "foo:int=1"), | ||||||
Check: acceptance.ComposeTestCheckFunc( | ||||||
check.That(data.ResourceName).ExistsInAzure(r), | ||||||
), | ||||||
}, | ||||||
data.ImportStep(), | ||||||
{ | ||||||
Config: r.function_parameter(data, "foo:(bar:long)"), | ||||||
Check: acceptance.ComposeTestCheckFunc( | ||||||
check.That(data.ResourceName).ExistsInAzure(r), | ||||||
), | ||||||
}, | ||||||
data.ImportStep(), | ||||||
}) | ||||||
} | ||||||
|
||||||
func TestAccLogAnalyticsSavedSearch_requiresImport(t *testing.T) { | ||||||
data := acceptance.BuildTestData(t, "azurerm_log_analytics_saved_search", "test") | ||||||
r := LogAnalyticsSavedSearchResource{} | ||||||
|
@@ -120,7 +149,7 @@ resource "azurerm_log_analytics_saved_search" "test" { | |||||
|
||||||
category = "Saved Search Test Category" | ||||||
display_name = "Create or Update Saved Search Test" | ||||||
query = "Heartbeat | summarize Count() by Computer | take a" | ||||||
query = "Heartbeat | summarize Count() by Computer | take 1" | ||||||
} | ||||||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||||||
} | ||||||
|
@@ -164,14 +193,46 @@ resource "azurerm_log_analytics_saved_search" "test" { | |||||
|
||||||
category = "Saved Search Test Category" | ||||||
display_name = "Create or Update Saved Search Test" | ||||||
query = "Heartbeat | summarize Count() by Computer | take a" | ||||||
query = "Heartbeat | summarize Count() by Computer | take 1" | ||||||
|
||||||
function_alias = "heartbeat_func" | ||||||
function_parameters = ["a:int=1", "b:int=2", "c:int=3"] | ||||||
} | ||||||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger) | ||||||
} | ||||||
|
||||||
func (LogAnalyticsSavedSearchResource) function_parameter(data acceptance.TestData, para string) string { | ||||||
return fmt.Sprintf(` | ||||||
provider "azurerm" { | ||||||
features {} | ||||||
} | ||||||
|
||||||
resource "azurerm_resource_group" "test" { | ||||||
name = "acctestRG-%d" | ||||||
location = "%s" | ||||||
} | ||||||
|
||||||
resource "azurerm_log_analytics_workspace" "test" { | ||||||
name = "acctestLAW-%d" | ||||||
location = azurerm_resource_group.test.location | ||||||
resource_group_name = azurerm_resource_group.test.name | ||||||
sku = "PerGB2018" | ||||||
} | ||||||
|
||||||
resource "azurerm_log_analytics_saved_search" "test" { | ||||||
name = "acctestLASS-%d" | ||||||
log_analytics_workspace_id = azurerm_log_analytics_workspace.test.id | ||||||
|
||||||
category = "Saved Search Test Category" | ||||||
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 if spaces are allowed here 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. per the testing result it should be fine |
||||||
display_name = "Create or Update Saved Search Test" | ||||||
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.
Suggested change
|
||||||
query = "Heartbeat | summarize Count() by Computer | take 1" | ||||||
|
||||||
function_alias = "heartbeat_func" | ||||||
function_parameters = ["%s"] | ||||||
} | ||||||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, para) | ||||||
} | ||||||
|
||||||
func (LogAnalyticsSavedSearchResource) withTag(data acceptance.TestData) string { | ||||||
return fmt.Sprintf(` | ||||||
provider "azurerm" { | ||||||
|
@@ -196,7 +257,7 @@ resource "azurerm_log_analytics_saved_search" "test" { | |||||
|
||||||
category = "Saved Search Test Category" | ||||||
display_name = "Create or Update Saved Search Test" | ||||||
query = "Heartbeat | summarize Count() by Computer | take a" | ||||||
query = "Heartbeat | summarize Count() by Computer | take 1" | ||||||
|
||||||
tags = { | ||||||
"Environment" = "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.
ideally a test case should be added that verifies multiple parameters as well, perhaps in 2-3 different forms, just to test the repetitive part of the regex
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.
multiple parameters are tested in the
TestAccLogAnalyticsSavedSearch_complete
test case