-
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 2 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{} | ||||||
|
@@ -172,6 +201,38 @@ resource "azurerm_log_analytics_saved_search" "test" { | |||||
`, 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 a" | ||||||
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
|
||||||
|
||||||
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" { | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -52,7 +52,7 @@ The following arguments are supported: | |||||
|
||||||
* `function_alias` - (Optional) The function alias if the query serves as a function. Changing this forces a new resource to be created. | ||||||
|
||||||
* `function_parameters` - (Optional) The function parameters if the query serves as a function. Changing this forces a new resource to be created. | ||||||
* `function_parameters` - (Optional) The function parameters if the query serves as a function. Changing this forces a new resource to be created. For more examples and proper syntax please refer to [this document](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/functions/user-defined-functions) | ||||||
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
|
||||||
|
||||||
* `tags` - (Optional) A mapping of tags which should be assigned to the Logs Analytics Saved Search. Changing this forces a new resource to be created. | ||||||
|
||||||
|
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