rano/pkg/user/create_test.go

39 lines
831 B
Go

package user
import (
"context"
"testing"
"github.com/brianvoe/gofakeit/v7"
)
func TestCreate(t *testing.T) {
t.Run("check nil", func(t *testing.T) {
if _, err := Create(context.Background(), nil); err == nil {
t.Error("nil check error expected")
}
})
t.Run("trigger validation errors", func(t *testing.T) {
if _, err := Create(context.Background(), &CreateInput{}); err == nil {
t.Error("validation errors are expected")
} else {
t.Log(err)
}
})
t.Run("create", func(t *testing.T) {
if _, err := Create(context.Background(), &CreateInput{
Email: gofakeit.Email(),
Pwd: "pwd123",
ConfirmPwd: "pwd123",
FirstName: gofakeit.FirstName(),
MiddleName: gofakeit.MiddleName(),
LastName: gofakeit.LastName(),
RoleID: 1,
}); err != nil {
t.Error(err)
}
})
}