From 60ab2b27eb537bc788f33e2f650aec4e806323da Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Wed, 17 Feb 2021 15:25:52 +0300 Subject: [PATCH] Correct declaration for Buttons --- response.go | 2 +- response_test.go | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 response_test.go diff --git a/response.go b/response.go index 2ae1a40..3f57ba9 100644 --- a/response.go +++ b/response.go @@ -508,7 +508,7 @@ type StructuredMessageElement struct { ItemURL string `json:"item_url,omitempty"` Subtitle string `json:"subtitle"` DefaultAction *DefaultAction `json:"default_action,omitempty"` - Buttons *[]StructuredMessageButton `json:"buttons"` + Buttons *[]StructuredMessageButton `json:"buttons,omitempty"` ReceiptMessageElement } diff --git a/response_test.go b/response_test.go new file mode 100644 index 0000000..cd0a26a --- /dev/null +++ b/response_test.go @@ -0,0 +1,17 @@ +package messenger + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_MarshalStructuredMessageElement(t *testing.T) { + data, err := json.Marshal(StructuredMessageElement{ + Title: "Title", + }) + require.NoError(t, err) + assert.JSONEq(t, string(data), `{"image_url":"", "subtitle":"", "title": "Title"}`) +}