mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-13 19:45:26 +00:00
Support for password resets
This commit is contained in:
39
codes/handler/create_test.go
Normal file
39
codes/handler/create_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package handler_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/micro/services/codes/handler"
|
||||
pb "github.com/micro/services/codes/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
h := testHandler(t)
|
||||
|
||||
t.Run("MissingIdentity", func(t *testing.T) {
|
||||
var rsp pb.CreateResponse
|
||||
err := h.Create(context.TODO(), &pb.CreateRequest{}, &rsp)
|
||||
assert.Equal(t, handler.ErrMissingIdentity, err)
|
||||
assert.Empty(t, rsp.Code)
|
||||
})
|
||||
|
||||
t.Run("NoExpiry", func(t *testing.T) {
|
||||
var rsp pb.CreateResponse
|
||||
err := h.Create(context.TODO(), &pb.CreateRequest{Identity: "07503196715"}, &rsp)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, rsp.Code)
|
||||
})
|
||||
|
||||
t.Run("WithExpiry", func(t *testing.T) {
|
||||
var rsp pb.CreateResponse
|
||||
err := h.Create(context.TODO(), &pb.CreateRequest{
|
||||
Identity: "demo@m3o.com",
|
||||
ExpiresAt: timestamppb.Now(),
|
||||
}, &rsp)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, rsp.Code)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user