Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tokuhirom committed Oct 25, 2023
1 parent 6065ca9 commit 8732446
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package tests


import (
"encoding/json"
"strings"
"testing"

"github.com/line/line-bot-sdk-go/v7/linebot/messaging_api"
)

func TestTemplateMessage(t *testing.T) {
req := &messaging_api.ReplyMessageRequest{
ReplyToken: "JKLJDSFhkljdsjfkla",
Messages: []messaging_api.MessageInterface{
&messaging_api.TemplateMessage{
AltText: "Buttons alt text",
Template: &messaging_api.ButtonsTemplate{
ThumbnailImageUrl: "https://example.com/static/buttons/1040.jpg",
Title: "My button sample",
Actions: []messaging_api.ActionInterface{
&messaging_api.UriAction{
Label: "Go to line.me",
Uri: "https://line.me",
},
},
},
},
},
}
encodedMsg, err := json.Marshal(req)
if err != nil {
t.Fatalf("Failed to encode message: %v", err)
}
encodedMsgStr := string(encodedMsg)
if !strings.Contains(encodedMsgStr, `"type":"buttons"`) {
t.Errorf("Encoded message doens't contains expected default value: %s", encodedMsgStr)
}
}

0 comments on commit 8732446

Please sign in to comment.