Skip to content

Commit

Permalink
azurerm_data_factory_dataset_json - filename and path in `azure…
Browse files Browse the repository at this point in the history
…_blob_storage_location` block can now be empty (#18061)

Co-authored-by: zjhe <[email protected]>
  • Loading branch information
lonegunmanb and lonegunmanb authored Aug 24, 2022
1 parent 2d18c62 commit 7470490
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,17 @@ func resourceDataFactoryDatasetJSON() *pluginsdk.Resource {
Default: false,
},
"path": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
Type: pluginsdk.TypeString,
Required: true,
},
"dynamic_path_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},
"filename": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringIsNotEmpty,
Type: pluginsdk.TypeString,
Required: true,
},
"dynamic_filename_enabled": {
Type: pluginsdk.TypeBool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ func TestAccDataFactoryDatasetJSON_blob(t *testing.T) {
})
}

func TestAccDataFactoryDatasetJSON_blobWithoutFileName(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_json", "test")
r := DatasetJSONResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.blobWithEmptyFileNameAndPath(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccDataFactoryDatasetJSON_blobDynamicContainer(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_json", "test")
r := DatasetJSONResource{}
Expand Down Expand Up @@ -399,3 +414,60 @@ resource "azurerm_data_factory_dataset_json" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

func (DatasetJSONResource) blobWithEmptyFileNameAndPath(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%d"
location = "%s"
}
resource "azurerm_storage_account" "test" {
name = "acctestdf%s"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
account_tier = "Standard"
account_replication_type = "GRS"
}
resource "azurerm_storage_container" "test" {
name = "content"
storage_account_name = azurerm_storage_account.test.name
container_access_type = "private"
}
resource "azurerm_data_factory" "test" {
name = "acctestdf%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}
resource "azurerm_data_factory_linked_service_azure_blob_storage" "test" {
name = "acctestlsblob%d"
data_factory_id = azurerm_data_factory.test.id
connection_string = azurerm_storage_account.test.primary_connection_string
}
resource "azurerm_data_factory_dataset_json" "test" {
name = "acctestds%d"
data_factory_id = azurerm_data_factory.test.id
linked_service_name = azurerm_data_factory_linked_service_azure_blob_storage.test.name
azure_blob_storage_location {
container = azurerm_storage_container.test.name
path = ""
dynamic_path_enabled = true
filename = ""
dynamic_filename_enabled = false
}
encoding = "UTF-8"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}

0 comments on commit 7470490

Please sign in to comment.