rano/pkg/user/create_test.go

39 lines
831 B
Go
Raw Normal View History

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