Skip to content

Commit 1fa495f

Browse files
authored
Force recreation of widget on changing its visualization ID (#898)
1 parent 9921c41 commit 1fa495f

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

sqlanalytics/resource_widget.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type WidgetEntity struct {
2222
Description string `json:"description,omitempty"`
2323

2424
Text string `json:"text,omitempty"`
25-
VisualizationID string `json:"visualization_id,omitempty"`
25+
VisualizationID string `json:"visualization_id,omitempty" tf:"force_new"`
2626

2727
Position *WidgetPosition `json:"position,omitempty"`
2828
Parameter []WidgetParameter `json:"parameter,omitempty" tf:"slice_set"`

sqlanalytics/resource_widget_test.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ func TestWidgetReadNotFound(t *testing.T) {
558558
}
559559

560560
func TestWidgetUpdate(t *testing.T) {
561-
sText := "text"
561+
sText := "new text"
562562

563563
d, err := qa.ResourceFixture{
564564
Fixtures: []qa.HTTPFixture{
@@ -589,12 +589,12 @@ func TestWidgetUpdate(t *testing.T) {
589589
json.RawMessage(`
590590
{
591591
"id": "12345",
592-
"text": "text"
592+
"text": "new text"
593593
}
594594
`),
595595
json.RawMessage(`
596596
{
597-
"id": "12345",
597+
"id": "12346",
598598
"visualization_id": null
599599
}
600600
`),
@@ -606,12 +606,12 @@ func TestWidgetUpdate(t *testing.T) {
606606
Update: true,
607607
ID: "some-uuid/12345",
608608
InstanceState: map[string]string{
609-
"dashboard_id": "some-uuid",
610-
"visualization_id": "678",
609+
"dashboard_id": "some-uuid",
610+
"text": "previous text",
611611
},
612612
HCL: `
613613
dashboard_id = "some-uuid"
614-
text = "text"
614+
text = "new text"
615615
`,
616616
}.Apply(t)
617617

@@ -620,17 +620,11 @@ func TestWidgetUpdate(t *testing.T) {
620620
assert.Equal(t, "some-uuid", d.Get("dashboard_id"))
621621
assert.Equal(t, "12345", d.Get("widget_id"))
622622

623-
// Test that visualization_id is now unset (see instance state).
624-
{
625-
_, ok := d.GetOk("visualization_id")
626-
assert.False(t, ok, "visualization_id should not be set")
627-
}
628-
629623
// Test that text is now set.
630624
{
631625
v, ok := d.GetOk("text")
632626
assert.True(t, ok, "text should be set")
633-
assert.Equal(t, "text", v)
627+
assert.Equal(t, "new text", v)
634628
}
635629
}
636630

0 commit comments

Comments
 (0)