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

b/Fix attribute name in slot_type_values #38856

Merged
merged 3 commits into from
Aug 14, 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
3 changes: 3 additions & 0 deletions .changelog/38856.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_lexv2models_slot_type: Fix slot_type_values to have sample_value attribute
```
10 changes: 5 additions & 5 deletions internal/service/lexv2models/slot_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func (r *resourceSlotType) Schema(ctx context.Context, req resource.SchemaReques
CustomType: fwtypes.NewListNestedObjectTypeOf[SlotTypeValues](ctx),
NestedObject: schema.NestedBlockObject{
Blocks: map[string]schema.Block{
"slot_type_value": schema.ListNestedBlock{
CustomType: fwtypes.NewListNestedObjectTypeOf[SlotTypeValue](ctx),
"sample_value": schema.ListNestedBlock{
CustomType: fwtypes.NewListNestedObjectTypeOf[SampleValue](ctx),
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
names.AttrValue: schema.StringAttribute{
Expand Down Expand Up @@ -481,13 +481,13 @@ type ExternalSourceSetting struct {
GrammarSlotTypeSetting fwtypes.ListNestedObjectValueOf[GrammarSlotTypeSetting] `tfsdk:"grammar_slot_type_setting"`
}

type SlotTypeValue struct {
type SampleValue struct {
Value types.String `tfsdk:"value"`
}

type SlotTypeValues struct {
SlotTypeValues fwtypes.ListNestedObjectValueOf[SlotTypeValue] `tfsdk:"slot_type_values"`
Synonyms fwtypes.ListNestedObjectValueOf[SlotTypeValue] `tfsdk:"synonyms"`
SampleValue fwtypes.ListNestedObjectValueOf[SampleValue] `tfsdk:"sample_value"`
Synonyms fwtypes.ListNestedObjectValueOf[SampleValue] `tfsdk:"synonyms"`
}

type AdvancedRecognitionSetting struct {
Expand Down
63 changes: 63 additions & 0 deletions internal/service/lexv2models/slot_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,46 @@ func TestAccLexV2ModelsSlotType_basic(t *testing.T) {
})
}

func TestAccLexV2ModelsSlotType_values(t *testing.T) {
ctx := acctest.Context(t)

var slottype lexmodelsv2.DescribeSlotTypeOutput
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_lexv2models_slot_type.test"
botLocaleName := "aws_lexv2models_bot_locale.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acctest.PreCheck(ctx, t)
acctest.PreCheckPartitionHasService(t, names.LexV2ModelsEndpointID)
testAccPreCheck(ctx, t)
},
ErrorCheck: acctest.ErrorCheck(t, names.LexV2ModelsServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckSlotTypeDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccSlotTypeConfig_values(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckSlotTypeExists(ctx, resourceName, &slottype),
resource.TestCheckResourceAttr(resourceName, names.AttrName, rName),
resource.TestCheckResourceAttrPair(resourceName, "bot_id", botLocaleName, "bot_id"),
resource.TestCheckResourceAttrPair(resourceName, "bot_version", botLocaleName, "bot_version"),
resource.TestCheckResourceAttrPair(resourceName, "locale_id", botLocaleName, "locale_id"),
resource.TestCheckResourceAttrSet(resourceName, "slot_type_values.#"),
resource.TestCheckResourceAttrSet(resourceName, "slot_type_values.0.%"),
resource.TestCheckResourceAttr(resourceName, "slot_type_values.0.sample_value.0.value", "testval"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccLexV2ModelsSlotType_disappears(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
Expand Down Expand Up @@ -208,3 +248,26 @@ resource "aws_lexv2models_slot_type" "test" {
}
`, rName))
}

func testAccSlotTypeConfig_values(rName string) string {
return acctest.ConfigCompose(
testAccSlotTypeConfig_base(rName, 60, true),
fmt.Sprintf(`
resource "aws_lexv2models_slot_type" "test" {
bot_id = aws_lexv2models_bot.test.id
bot_version = aws_lexv2models_bot_locale.test.bot_version
name = %[1]q
locale_id = aws_lexv2models_bot_locale.test.locale_id

value_selection_setting {
resolution_strategy = "OriginalValue"
}

slot_type_values {
sample_value {
value = "testval"
}
}
}
`, rName))
}
Loading