rano/pkg/user/create_test.go
2024-11-18 20:53:13 +05:30

43 lines
988 B
Go

// Copyright 2024 Patial Tech. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
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)
}
})
}