mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
Update threads to use model/store (#97)
This commit is contained in:
49
threads/handler/delete_thread_test.go
Normal file
49
threads/handler/delete_thread_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package handler_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/micro/services/threads/handler"
|
||||
pb "github.com/micro/services/threads/proto"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDeleteThread(t *testing.T) {
|
||||
h := testHandler(t)
|
||||
|
||||
// seed some data
|
||||
var cRsp pb.CreateThreadResponse
|
||||
err := h.CreateThread(microAccountCtx(), &pb.CreateThreadRequest{
|
||||
Topic: "HelloWorld", GroupId: uuid.New().String(),
|
||||
}, &cRsp)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating thread: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
t.Run("MissingID", func(t *testing.T) {
|
||||
err := h.DeleteThread(microAccountCtx(), &pb.DeleteThreadRequest{}, &pb.DeleteThreadResponse{})
|
||||
assert.Equal(t, handler.ErrMissingID, err)
|
||||
})
|
||||
|
||||
t.Run("Valid", func(t *testing.T) {
|
||||
err := h.DeleteThread(microAccountCtx(), &pb.DeleteThreadRequest{
|
||||
Id: cRsp.Thread.Id,
|
||||
}, &pb.DeleteThreadResponse{})
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = h.ReadThread(microAccountCtx(), &pb.ReadThreadRequest{
|
||||
Id: cRsp.Thread.Id,
|
||||
}, &pb.ReadThreadResponse{})
|
||||
assert.Equal(t, handler.ErrNotFound, err)
|
||||
})
|
||||
|
||||
t.Run("Retry", func(t *testing.T) {
|
||||
err := h.DeleteThread(microAccountCtx(), &pb.DeleteThreadRequest{
|
||||
Id: cRsp.Thread.Id,
|
||||
}, &pb.DeleteThreadResponse{})
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user