Skip to content

Commit

Permalink
azurerm_automation_runbook - allow invalid publish_content_links (#7824)
Browse files Browse the repository at this point in the history
fixes #7809

--- PASS: TestAccAzureRMAutomationRunbook_PSWithContent (139.64s)
--- PASS: TestAccAzureRMAutomationRunbook_PSWorkflowWithHash (139.87s)
--- PASS: TestAccAzureRMAutomationRunbook_PSWorkflow (140.07s)
--- PASS: TestAccAzureRMAutomationRunbook_PSWorkflowWithoutUri (140.27s)
--- PASS: TestAccAzureRMAutomationRunbook_requiresImport (148.20s)
PASS
  • Loading branch information
Neil Ye committed Jul 24, 2020
1 parent 63855bc commit 8749a0a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
Expand Up @@ -259,7 +259,11 @@ func resourceArmAutomationRunbookRead(d *schema.ResourceData, meta interface{})

response, err := client.GetContent(ctx, resGroup, accName, name)
if err != nil {
return fmt.Errorf("Error retrieving content for Automation Runbook %q (Account %q / Resource Group %q): %+v", name, accName, resGroup, err)
if utils.ResponseWasNotFound(response.Response) {
d.Set("content", "")
} else {
return fmt.Errorf("retrieving content for Automation Runbook %q (Account %q / Resource Group %q): %+v", name, accName, resGroup, err)
}
}

if v := response.Value; v != nil {
Expand Down
Expand Up @@ -90,6 +90,25 @@ func TestAccAzureRMAutomationRunbook_PSWithContent(t *testing.T) {
})
}

func TestAccAzureRMAutomationRunbook_PSWorkflowWithoutUri(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_automation_runbook", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMAutomationRunbookDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMAutomationRunbook_PSWorkflowWithoutUri(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMAutomationRunbookExists(data.ResourceName),
),
},
data.ImportStep("publish_content_link"),
},
})
}

func testCheckAzureRMAutomationRunbookDestroy(s *terraform.State) error {
conn := acceptance.AzureProvider.Meta().(*clients.Client).Automation.RunbookClient
ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext
Expand Down Expand Up @@ -300,3 +319,39 @@ CONTENT
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func testAccAzureRMAutomationRunbook_PSWorkflowWithoutUri(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_automation_account" "test" {
name = "acctest-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "Basic"
}
resource "azurerm_automation_runbook" "test" {
name = "Get-AzureVMTutorial"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
automation_account_name = azurerm_automation_account.test.name
log_verbose = "true"
log_progress = "true"
description = "This is a test runbook for terraform acceptance test"
runbook_type = "PowerShell"
publish_content_link {
uri = ""
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

0 comments on commit 8749a0a

Please sign in to comment.