Add idempotent_id to chat and threads services (#64)

* Add idempotent_id to chat and threads services

* Rename
This commit is contained in:
ben-toogood
2021-02-05 11:22:48 +00:00
committed by GitHub
parent b850b61085
commit 2c53892bc6
9 changed files with 235 additions and 156 deletions

View File

@@ -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)
})
}