mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-12 03:05:14 +00:00
Add idempotent_id to chat and threads services (#64)
* Add idempotent_id to chat and threads services * Rename
This commit is contained in:
@@ -25,12 +25,14 @@ func TestCreateMessage(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
iid := uuid.New().String()
|
||||
tt := []struct {
|
||||
Name string
|
||||
AuthorID string
|
||||
ChatID string
|
||||
Text string
|
||||
Error error
|
||||
ID string
|
||||
}{
|
||||
{
|
||||
Name: "MissingChatID",
|
||||
@@ -58,18 +60,35 @@ func TestCreateMessage(t *testing.T) {
|
||||
Error: handler.ErrNotFound,
|
||||
},
|
||||
{
|
||||
Name: "Valid",
|
||||
Name: "WithoutID",
|
||||
ChatID: cRsp.Chat.Id,
|
||||
AuthorID: uuid.New().String(),
|
||||
Text: "HelloWorld",
|
||||
},
|
||||
{
|
||||
Name: "WithID",
|
||||
ChatID: cRsp.Chat.Id,
|
||||
AuthorID: "johndoe",
|
||||
Text: "HelloWorld",
|
||||
ID: iid,
|
||||
},
|
||||
{
|
||||
Name: "RepeatID",
|
||||
ChatID: cRsp.Chat.Id,
|
||||
AuthorID: "johndoe",
|
||||
Text: "HelloWorld",
|
||||
ID: iid,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tt {
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
var rsp pb.CreateMessageResponse
|
||||
err := h.CreateMessage(context.TODO(), &pb.CreateMessageRequest{
|
||||
Text: tc.Text, ChatId: tc.ChatID, AuthorId: tc.AuthorID,
|
||||
AuthorId: tc.AuthorID,
|
||||
ChatId: tc.ChatID,
|
||||
Text: tc.Text,
|
||||
Id: tc.ID,
|
||||
}, &rsp)
|
||||
|
||||
assert.Equal(t, tc.Error, err)
|
||||
@@ -83,6 +102,7 @@ func TestCreateMessage(t *testing.T) {
|
||||
ChatId: tc.ChatID,
|
||||
SentAt: timestamppb.New(h.Time()),
|
||||
Text: tc.Text,
|
||||
Id: tc.ID,
|
||||
}, rsp.Message)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user