feat: remove phone (#349)

* feat: remove phone number

* feat: remove phone number tests

* feat: remove phone number tests

* fix: regenerate protos
This commit is contained in:
Fabi
2020-07-06 15:48:24 +02:00
committed by GitHub
parent 0e1ef5758a
commit c8cdbe136c
31 changed files with 1947 additions and 1430 deletions

View File

@@ -2604,6 +2604,70 @@ func TestVerifyPhone(t *testing.T) {
}
}
func TestRemovePhone(t *testing.T) {
ctrl := gomock.NewController(t)
type args struct {
es *UserEventstore
ctx context.Context
userID string
code string
}
type res struct {
errFunc func(err error) bool
}
tests := []struct {
name string
args args
res res
}{
{
name: "remove phone ok",
args: args{
es: GetMockManipulateUserVerifiedPhone(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
userID: "AggregateID",
code: "code",
},
res: res{},
},
{
name: "empty userid",
args: args{
es: GetMockManipulateUser(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
code: "Code",
},
res: res{
errFunc: caos_errs.IsPreconditionFailed,
},
},
{
name: "existing user not found",
args: args{
es: GetMockManipulateUserNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
userID: "AggregateID",
code: "Code",
},
res: res{
errFunc: caos_errs.IsNotFound,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.args.es.RemovePhone(tt.args.ctx, tt.args.userID)
if tt.res.errFunc == nil && err != nil {
t.Errorf("should not get err %v", err)
}
if tt.res.errFunc != nil && !tt.res.errFunc(err) {
t.Errorf("got wrong err: %v ", err)
}
})
}
}
func TestCreatePhoneVerificationCode(t *testing.T) {
ctrl := gomock.NewController(t)
type args struct {