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,10 +25,12 @@ func TestCreateMessage(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
iid := uuid.New().String()
|
||||
tt := []struct {
|
||||
Name string
|
||||
AuthorID string
|
||||
ConversationID string
|
||||
ID string
|
||||
Text string
|
||||
Error error
|
||||
}{
|
||||
@@ -58,18 +60,35 @@ func TestCreateMessage(t *testing.T) {
|
||||
Error: handler.ErrNotFound,
|
||||
},
|
||||
{
|
||||
Name: "Valid",
|
||||
Name: "NoID",
|
||||
ConversationID: cRsp.Conversation.Id,
|
||||
AuthorID: uuid.New().String(),
|
||||
Text: "HelloWorld",
|
||||
},
|
||||
{
|
||||
Name: "WithID",
|
||||
ConversationID: cRsp.Conversation.Id,
|
||||
Text: "HelloWorld",
|
||||
AuthorID: "johndoe",
|
||||
ID: iid,
|
||||
},
|
||||
{
|
||||
Name: "RepeatID",
|
||||
ConversationID: cRsp.Conversation.Id,
|
||||
Text: "HelloWorld",
|
||||
AuthorID: "johndoe",
|
||||
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, ConversationId: tc.ConversationID, AuthorId: tc.AuthorID,
|
||||
AuthorId: tc.AuthorID,
|
||||
ConversationId: tc.ConversationID,
|
||||
Text: tc.Text,
|
||||
Id: tc.ID,
|
||||
}, &rsp)
|
||||
|
||||
assert.Equal(t, tc.Error, err)
|
||||
@@ -79,6 +98,7 @@ func TestCreateMessage(t *testing.T) {
|
||||
}
|
||||
|
||||
assertMessagesMatch(t, &pb.Message{
|
||||
Id: tc.ID,
|
||||
AuthorId: tc.AuthorID,
|
||||
ConversationId: tc.ConversationID,
|
||||
SentAt: timestamppb.New(h.Time()),
|
||||
|
||||
Reference in New Issue
Block a user