Ejemplo n.º 1
0
import (
	"github.com/AitorGuerrero/UserGo/user"

	t "testing"
)

type fakeEncryptor struct{}

func (fakeEncryptor) Encrypt(i string) string {
	return i
}

var e fakeEncryptor
var pe user.PasskeyEncryptor
var i = user.ParseId("de1ec52a-21c6-491c-99f9-6f29bc1d565f")
var p user.Passkey
var u user.User
var mngu User

func beforeEach() {
	e = fakeEncryptor{}
	pe = user.PasskeyEncryptor{e}
	p = pe.Encrypt(i, "passkey")
	u = user.New(i, p)
}

func TestShouldCreateAMngUserFromDomainUser(t *t.T) {
	mngu = FromDomainUser(u)
	if mngu.Id != u.Id().Serialize() {
		t.Error("The Id should be the same")
Ejemplo n.º 2
0
func FromMngUser(mngu User) user.User {
	u = user.New(user.ParseId(mngu.Id), user.Passkey(mngu.Passkey))

	return u
}