44 lines
1 KiB
Go
44 lines
1 KiB
Go
package store
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.ctrlz.es/mgdelacroix/rmsn/model"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateUser(t *testing.T) {
|
|
th, teardown := NewTestHelper(t)
|
|
defer teardown()
|
|
|
|
user := &model.User{
|
|
Name: "John",
|
|
Mail: "john_doe@example.com",
|
|
Username: "john_doe",
|
|
Password: "mysupersecret",
|
|
}
|
|
|
|
newUser, err := th.store.User().Create(user)
|
|
require.NoError(t, err)
|
|
require.NotZero(t, newUser.ID)
|
|
require.Equal(t, user.Name, newUser.Name)
|
|
require.Equal(t, user.Mail, newUser.Mail)
|
|
require.Equal(t, user.Username, newUser.Username)
|
|
require.Equal(t, user.Password, newUser.Password)
|
|
}
|
|
|
|
func TestGetByID(t *testing.T) {
|
|
th, teardown := NewTestHelper(t)
|
|
defer teardown()
|
|
|
|
user := th.NewUser()
|
|
|
|
user2, err := th.store.User().GetByID(user.ID)
|
|
require.NoError(t, err)
|
|
require.Equal(t, user.ID, user2.ID)
|
|
require.Equal(t, user.Name, user2.Name)
|
|
require.Equal(t, user.Mail, user2.Mail)
|
|
require.Equal(t, user.Username, user2.Username)
|
|
require.Equal(t, user.Password, user2.Password)
|
|
}
|