Skip to content

Commit

Permalink
chore(test): drop message id constant
Browse files Browse the repository at this point in the history
  • Loading branch information
crispgm committed Nov 29, 2023
1 parent 7c6db38 commit 1479de9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
25 changes: 12 additions & 13 deletions api_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,6 @@ func TestMessageCRUD(t *testing.T) {
if assert.NoError(t, err) {
t.Log(receipt.Data.ReadUsers)
}
// receipt read
receiptOld, err := bot.MessageReadReceipt(testMessageID)
if assert.NoError(t, err) {
// failed because the message ID will be outdated after tens of days
// assert.NotEmpty(t, receiptOld.Data.ReadUsers)
t.Log(receiptOld.Data.ReadUsers)
}
}

func TestIdempotentMessage(t *testing.T) {
Expand All @@ -437,12 +430,18 @@ func TestIdempotentMessage(t *testing.T) {
}

func TestPinMessages(t *testing.T) {
resp, err := bot.PinMessage(testMessageID)
msg := NewMsgBuffer(MsgText)
om := msg.BindEmail(testUserEmail).Text("hello, world").Build()
resp, err := bot.PostMessage(om)
if assert.NoError(t, err) {
assert.Equal(t, 0, resp.Code)
assert.Equal(t, testMessageID, resp.Data.Pin.MessageID)
unpinResp, err := bot.UnpinMessage(testMessageID)
assert.NoError(t, err)
assert.Equal(t, 0, unpinResp.Code)
messageID := resp.Data.MessageID
resp, err := bot.PinMessage(messageID)
if assert.NoError(t, err) {
assert.Equal(t, 0, resp.Code)
assert.Equal(t, messageID, resp.Data.Pin.MessageID)
unpinResp, err := bot.UnpinMessage(messageID)
assert.NoError(t, err)
assert.Equal(t, 0, unpinResp.Code)
}
}
}
5 changes: 1 addition & 4 deletions lark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var (
testUserID string
testUserUnionID string
testGroupChatID string
testMessageID string
testWebhookV1 string
testWebhookV2 string
testWebhookV2Signed string
Expand All @@ -48,7 +47,6 @@ func newTestBot() *Bot {
testUserUnionID = os.Getenv("LARK_UNION_ID")
testUserOpenID = os.Getenv("LARK_OPEN_ID")
testGroupChatID = os.Getenv("LARK_CHAT_ID")
testMessageID = os.Getenv("LARK_MESSAGE_ID")
testWebhookV1 = os.Getenv("LARK_WEBHOOK_V1")
testWebhookV2 = os.Getenv("LARK_WEBHOOK_V2")
testWebhookV2Signed = os.Getenv("LARK_WEBHOOK_V2_SIGNED")
Expand All @@ -58,8 +56,7 @@ func newTestBot() *Bot {
len(testUserID) == 0 ||
len(testUserUnionID) == 0 ||
len(testUserOpenID) == 0 ||
len(testGroupChatID) == 0 ||
len(testMessageID) == 0 {
len(testGroupChatID) == 0 {
panic("insufficient test environment")
}
return NewChatBot(testAppID, testAppSecret)
Expand Down
4 changes: 2 additions & 2 deletions msg_buf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func TestBindingUserIDs(t *testing.T) {
assert.Equal(t, "333444", msgUserID.UserID)

mb.Clear()
msgReplyID := mb.BindReply(testMessageID).Build()
assert.Equal(t, testMessageID, msgReplyID.RootID)
msgReplyID := mb.BindReply("om_f779ffe0ffa3d1b94fc1ef5fcb6f1063").Build()
assert.Equal(t, "om_f779ffe0ffa3d1b94fc1ef5fcb6f1063", msgReplyID.RootID)
}

func TestMsgShareChat(t *testing.T) {
Expand Down

0 comments on commit 1479de9

Please sign in to comment.