Skip to content
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_app_configuration_feature - fix feature flags are not valid #26506

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func (k FeatureResource) Update() sdk.ResourceFunc {
Parameters: PercentageFilterParameters{Value: model.PercentageFilter},
})
filterChanged = true
} else {
} else if percentageFilter.Name != "" {
filters = append(filters, percentageFilter)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,27 @@ func TestAccAppConfigurationFeature_enabledUpdate(t *testing.T) {
})
}

func TestAccAppConfigurationFeature_basicAddTargetingFilter(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_app_configuration_feature", "test")
r := AppConfigurationFeatureResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicNoFilters(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.basicTargetingFilter(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (t AppConfigurationFeatureResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
nestedItemId, err := parse.ParseNestedItemID(state.ID)
if err != nil {
Expand Down Expand Up @@ -480,6 +501,27 @@ resource "azurerm_app_configuration_feature" "test" {
`, t.template(data), data.RandomInteger)
}

func (t AppConfigurationFeatureResource) basicTargetingFilter(data acceptance.TestData) string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test, looks like a required argument is missing here though:

------- Stdout: -------
=== RUN   TestAccAppConfigurationFeature_basicAddTargetingFilter
=== PAUSE TestAccAppConfigurationFeature_basicAddTargetingFilter
=== CONT  TestAccAppConfigurationFeature_basicAddTargetingFilter
    testcase.go:113: Step 3/4 error: Error running pre-apply refresh: exit status 1
        Error: Missing required argument
          on terraform_plugin_test.tf line 59, in resource "azurerm_app_configuration_feature" "test":
          59:   targeting_filter {
        The argument "default_rollout_percentage" is required, but no definition was
        found.

return fmt.Sprintf(`
%s

resource "azurerm_app_configuration_feature" "test" {
configuration_store_id = azurerm_app_configuration.test.id
description = "test description"
name = "acctest-ackey-%[2]d"
label = "acctest-ackeylabel-%[2]d"
enabled = true

targeting_filter {
default_rollout_percentage = 39
users = [
"random", "user"
]
}
}
`, t.template(data), data.RandomInteger)
}

func (t AppConfigurationFeatureResource) template(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
Loading