2024-11-15 16:12:15 +00:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
2024-11-17 16:58:29 +00:00
|
|
|
|
|
|
|
"github.com/brianvoe/gofakeit/v7"
|
2024-11-15 16:12:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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{
|
2024-11-17 16:58:29 +00:00
|
|
|
Email: gofakeit.Email(),
|
2024-11-15 16:12:15 +00:00
|
|
|
Pwd: "pwd123",
|
|
|
|
ConfirmPwd: "pwd123",
|
2024-11-17 16:58:29 +00:00
|
|
|
FirstName: gofakeit.FirstName(),
|
|
|
|
MiddleName: gofakeit.MiddleName(),
|
|
|
|
LastName: gofakeit.LastName(),
|
2024-11-15 16:12:15 +00:00
|
|
|
RoleID: 1,
|
|
|
|
}); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|