* Streams Service (WIP)

* Complete Streams Service
This commit is contained in:
ben-toogood
2021-01-25 14:35:11 +00:00
committed by GitHub
parent 055517ec14
commit 47fe6b39ec
28 changed files with 2971 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
package handler_test
import (
"context"
"testing"
"github.com/micro/services/streams/handler"
pb "github.com/micro/services/streams/proto"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)
func TestDeleteConversation(t *testing.T) {
h := testHandler(t)
// seed some data
var cRsp pb.CreateConversationResponse
err := h.CreateConversation(context.TODO(), &pb.CreateConversationRequest{
Topic: "HelloWorld", GroupId: uuid.New().String(),
}, &cRsp)
if err != nil {
t.Fatalf("Error creating conversation: %v", err)
return
}
t.Run("MissingID", func(t *testing.T) {
err := h.DeleteConversation(context.TODO(), &pb.DeleteConversationRequest{}, &pb.DeleteConversationResponse{})
assert.Equal(t, handler.ErrMissingID, err)
})
t.Run("Valid", func(t *testing.T) {
err := h.DeleteConversation(context.TODO(), &pb.DeleteConversationRequest{
Id: cRsp.Conversation.Id,
}, &pb.DeleteConversationResponse{})
assert.NoError(t, err)
err = h.ReadConversation(context.TODO(), &pb.ReadConversationRequest{
Id: cRsp.Conversation.Id,
}, &pb.ReadConversationResponse{})
assert.Equal(t, handler.ErrNotFound, err)
})
t.Run("Retry", func(t *testing.T) {
err := h.DeleteConversation(context.TODO(), &pb.DeleteConversationRequest{
Id: cRsp.Conversation.Id,
}, &pb.DeleteConversationResponse{})
assert.NoError(t, err)
})
}