Repository: slack-go/slack
Pull request #781 (2020-08-18 01:11:25)

Revert "Add description field to option block object"
Reverts slack-go/slack#766


Patch:
diff --git a/block_element.go b/block_element.go
index 766dd62..bca4e31 100644
--- a/block_element.go
+++ b/block_element.go
@@ -387,7 +387,7 @@ func (c CheckboxGroupsBlockElement) ElementType() MessageElementType {
 	return c.Type
 }
 
-// NewCheckboxGroupsBlockElement returns an instance of a checkbox-group block element
+// NewCheckboxGroupsBlockElement returns an instance of a radio block element
 func NewCheckboxGroupsBlockElement(actionID string, options ...*OptionBlockObject) *CheckboxGroupsBlockElement {
 	return &CheckboxGroupsBlockElement{
 		Type:     METCheckboxGroups,
diff --git a/block_object.go b/block_object.go
index a885722..d3f5074 100644
--- a/block_object.go
+++ b/block_object.go
@@ -187,18 +187,16 @@ func NewConfirmationBlockObject(title, text, confirm, deny *TextBlockObject) *Co
 //
 // More Information: https://api.slack.com/reference/messaging/composition-objects#option
 type OptionBlockObject struct {
-	Text        *TextBlockObject `json:"text"`
-	Value       string           `json:"value"`
-	Description *TextBlockObject `json:"description,omitempty"`
-	URL         string           `json:"url,omitempty"`
+	Text  *TextBlockObject `json:"text"`
+	Value string           `json:"value"`
+	URL   string           `json:"url,omitempty"`
 }
 
 // NewOptionBlockObject returns an instance of a new Option Block Element
-func NewOptionBlockObject(value string, text, description *TextBlockObject) *OptionBlockObject {
+func NewOptionBlockObject(value string, text *TextBlockObject) *OptionBlockObject {
 	return &OptionBlockObject{
-		Text:        text,
-		Value:       value,
-		Description: description,
+		Text:  text,
+		Value: value,
 	}
 }
 
diff --git a/examples/blocks/blocks.go b/examples/blocks/blocks.go
index d085123..38d6076 100644
--- a/examples/blocks/blocks.go
+++ b/examples/blocks/blocks.go
@@ -283,9 +283,9 @@ func exampleFive() {
 	overflowOptionTextThree := slack.NewTextBlockObject("plain_text", "Option Three", false, false)
 
 	// Build each option, providing a value for the option
-	overflowOptionOne := slack.NewOptionBlockObject("value-0", overflowOptionTextOne, nil)
-	overflowOptionTwo := slack.NewOptionBlockObject("value-1", overflowOptionTextTwo, nil)
-	overflowOptionThree := slack.NewOptionBlockObject("value-2", overflowOptionTextThree, nil)
+	overflowOptionOne := slack.NewOptionBlockObject("value-0", overflowOptionTextOne)
+	overflowOptionTwo := slack.NewOptionBlockObject("value-1", overflowOptionTextTwo)
+	overflowOptionThree := slack.NewOptionBlockObject("value-2", overflowOptionTextThree)
 
 	// Build overflow section
 	overflow := slack.NewOverflowBlockElement("", overflowOptionOne, overflowOptionTwo, overflowOptionThree)
@@ -365,9 +365,9 @@ func exampleSix() {
 	readTxt := slack.NewTextBlockObject("plain_text", "Read it", false, false)
 	saveTxt := slack.NewTextBlockObject("plain_text", "Save it", false, false)
 
-	editOpt := slack.NewOptionBlockObject("value-0", editTxt, nil)
-	readOpt := slack.NewOptionBlockObject("value-1", readTxt, nil)
-	saveOpt := slack.NewOptionBlockObject("value-2", saveTxt, nil)
+	editOpt := slack.NewOptionBlockObject("value-0", editTxt)
+	readOpt := slack.NewOptionBlockObject("value-1", readTxt)
+	saveOpt := slack.NewOptionBlockObject("value-2", saveTxt)
 
 	availableOption := slack.NewOptionsSelectBlockElement("static_select", manageTxt, "", editOpt, readOpt, saveOpt)
 


Test patch:
diff --git a/block_element_test.go b/block_element_test.go
index 68c1dfd..651930c 100644
--- a/block_element_test.go
+++ b/block_element_test.go
@@ -31,7 +31,7 @@ func TestNewButtonBlockElement(t *testing.T) {
 func TestNewOptionsSelectBlockElement(t *testing.T) {
 
 	testOptionText := NewTextBlockObject("plain_text", "Option One", false, false)
-	testOption := NewOptionBlockObject("test", testOptionText, nil)
+	testOption := NewOptionBlockObject("test", testOptionText)
 
 	option := NewOptionsSelectBlockElement("static_select", nil, "test", testOption)
 	assert.Equal(t, option.Type, "static_select")
@@ -43,13 +43,13 @@ func TestNewOptionsSelectBlockElement(t *testing.T) {
 func TestNewOptionsGroupSelectBlockElement(t *testing.T) {
 
 	testOptionText := NewTextBlockObject("plain_text", "Option One", false, false)
-	testOption := NewOptionBlockObject("test", testOptionText, nil)
+	testOption := NewOptionBlockObject("test", testOptionText)
 	testLabel := NewTextBlockObject("plain_text", "Test Label", false, false)
 	testGroupOption := NewOptionGroupBlockElement(testLabel, testOption)
 
 	optGroup := NewOptionsGroupSelectBlockElement("static_select", nil, "test", testGroupOption)
 
-	assert.Equal(t, optGroup.Type, "static_select")
+	assert.Equal(t, string(optGroup.Type), "static_select")
 	assert.Equal(t, optGroup.ActionID, "test")
 	assert.Equal(t, len(optGroup.OptionGroups), 1)
 
@@ -58,8 +58,7 @@ func TestNewOptionsGroupSelectBlockElement(t *testing.T) {
 func TestNewOptionsMultiSelectBlockElement(t *testing.T) {
 
 	testOptionText := NewTextBlockObject("plain_text", "Option One", false, false)
-	testDescriptionText := NewTextBlockObject("plain_text", "Description One", false, false)
-	testOption := NewOptionBlockObject("test", testOptionText, testDescriptionText)
+	testOption := NewOptionBlockObject("test", testOptionText)
 
 	option := NewOptionsMultiSelectBlockElement("static_select", nil, "test", testOption)
 	assert.Equal(t, option.Type, "static_select")
@@ -71,13 +70,13 @@ func TestNewOptionsMultiSelectBlockElement(t *testing.T) {
 func TestNewOptionsGroupMultiSelectBlockElement(t *testing.T) {
 
 	testOptionText := NewTextBlockObject("plain_text", "Option One", false, false)
-	testOption := NewOptionBlockObject("test", testOptionText, nil)
+	testOption := NewOptionBlockObject("test", testOptionText)
 	testLabel := NewTextBlockObject("plain_text", "Test Label", false, false)
 	testGroupOption := NewOptionGroupBlockElement(testLabel, testOption)
 
 	optGroup := NewOptionsGroupMultiSelectBlockElement("static_select", nil, "test", testGroupOption)
 
-	assert.Equal(t, optGroup.Type, "static_select")
+	assert.Equal(t, string(optGroup.Type), "static_select")
 	assert.Equal(t, optGroup.ActionID, "test")
 	assert.Equal(t, len(optGroup.OptionGroups), 1)
 
@@ -90,9 +89,9 @@ func TestNewOverflowBlockElement(t *testing.T) {
 	overflowOptionTextThree := NewTextBlockObject("plain_text", "Option Three", false, false)
 
 	// Build each option, providing a value for the option
-	overflowOptionOne := NewOptionBlockObject("value-0", overflowOptionTextOne, nil)
-	overflowOptionTwo := NewOptionBlockObject("value-1", overflowOptionTextTwo, nil)
-	overflowOptionThree := NewOptionBlockObject("value-2", overflowOptionTextThree, nil)
+	overflowOptionOne := NewOptionBlockObject("value-0", overflowOptionTextOne)
+	overflowOptionTwo := NewOptionBlockObject("value-1", overflowOptionTextTwo)
+	overflowOptionThree := NewOptionBlockObject("value-2", overflowOptionTextThree)
 
 	// Build overflow section
 	overflowElement := NewOverflowBlockElement("test", overflowOptionOne, overflowOptionTwo, overflowOptionThree)
@@ -114,36 +113,13 @@ func TestNewDatePickerBlockElement(t *testing.T) {
 
 func TestNewPlainTextInputBlockElement(t *testing.T) {
 
-	plainTextInputElement := NewPlainTextInputBlockElement(nil, "test")
+	plainTextInputElemnet := NewPlainTextInputBlockElement(nil, "test")
 
-	assert.Equal(t, string(plainTextInputElement.Type), "plain_text_input")
-	assert.Equal(t, plainTextInputElement.ActionID, "test")
+	assert.Equal(t, string(plainTextInputElemnet.Type), "plain_text_input")
+	assert.Equal(t, plainTextInputElemnet.ActionID, "test")
 
 }
 
-func TestNewCheckboxGroupsBlockElement(t *testing.T) {
-	// Build Text Objects associated with each option
-	checkBoxOptionTextOne := NewTextBlockObject("plain_text", "Check One", false, false)
-	checkBoxOptionTextTwo := NewTextBlockObject("plain_text", "Check Two", false, false)
-	checkBoxOptionTextThree := NewTextBlockObject("plain_text", "Check Three", false, false)
-
-	checkBoxDescriptionTextOne := NewTextBlockObject("plain_text", "Description One", false, false)
-	checkBoxDescriptionTextTwo := NewTextBlockObject("plain_text", "Description Two", false, false)
-	checkBoxDescriptionTextThree := NewTextBlockObject("plain_text", "Description Three", false, false)
-
-	// Build each option, providing a value for the option
-	checkBoxOptionOne := NewOptionBlockObject("value-0", checkBoxOptionTextOne, checkBoxDescriptionTextOne)
-	checkBoxOptionTwo := NewOptionBlockObject("value-1", checkBoxOptionTextTwo, checkBoxDescriptionTextTwo)
-	checkBoxOptionThree := NewOptionBlockObject("value-2", checkBoxOptionTextThree, checkBoxDescriptionTextThree)
-
-	// Build checkbox-group element
-	checkBoxGroupElement := NewCheckboxGroupsBlockElement("test", checkBoxOptionOne, checkBoxOptionTwo, checkBoxOptionThree)
-
-	assert.Equal(t, string(checkBoxGroupElement.Type), "checkboxes")
-	assert.Equal(t, checkBoxGroupElement.ActionID, "test")
-	assert.Equal(t, len(checkBoxGroupElement.Options), 3)
-}
-
 func TestNewRadioButtonsBlockElement(t *testing.T) {
 
 	// Build Text Objects associated with each option
@@ -152,11 +128,11 @@ func TestNewRadioButtonsBlockElement(t *testing.T) {
 	radioButtonsOptionTextThree := NewTextBlockObject("plain_text", "Option Three", false, false)
 
 	// Build each option, providing a value for the option
-	radioButtonsOptionOne := NewOptionBlockObject("value-0", radioButtonsOptionTextOne, nil)
-	radioButtonsOptionTwo := NewOptionBlockObject("value-1", radioButtonsOptionTextTwo, nil)
-	radioButtonsOptionThree := NewOptionBlockObject("value-2", radioButtonsOptionTextThree, nil)
+	radioButtonsOptionOne := NewOptionBlockObject("value-0", radioButtonsOptionTextOne)
+	radioButtonsOptionTwo := NewOptionBlockObject("value-1", radioButtonsOptionTextTwo)
+	radioButtonsOptionThree := NewOptionBlockObject("value-2", radioButtonsOptionTextThree)
 
-	// Build radio button element
+	// Build overflow section
 	radioButtonsElement := NewRadioButtonsBlockElement("test", radioButtonsOptionOne, radioButtonsOptionTwo, radioButtonsOptionThree)
 
 	assert.Equal(t, string(radioButtonsElement.Type), "radio_buttons")
diff --git a/block_object_test.go b/block_object_test.go
index 0f08ce1..3b001e5 100644
--- a/block_object_test.go
+++ b/block_object_test.go
@@ -45,11 +45,9 @@ func TestNewConfirmationBlockObject(t *testing.T) {
 func TestNewOptionBlockObject(t *testing.T) {
 
 	valTextObj := NewTextBlockObject("plain_text", "testText", false, false)
-	valDescriptionObj := NewTextBlockObject("plain_text", "testDescription", false, false)
-	optObj := NewOptionBlockObject("testOpt", valTextObj, valDescriptionObj)
+	optObj := NewOptionBlockObject("testOpt", valTextObj)
 
 	assert.Equal(t, optObj.Text.Text, "testText")
-	assert.Equal(t, optObj.Description.Text, "testDescription")
 	assert.Equal(t, optObj.Value, "testOpt")
 
 }
@@ -58,7 +56,7 @@ func TestNewOptionGroupBlockElement(t *testing.T) {
 
 	labelObj := NewTextBlockObject("plain_text", "testLabel", false, false)
 	valTextObj := NewTextBlockObject("plain_text", "testText", false, false)
-	optObj := NewOptionBlockObject("testOpt", valTextObj, nil)
+	optObj := NewOptionBlockObject("testOpt", valTextObj)
 
 	optGroup := NewOptionGroupBlockElement(labelObj, optObj)