package store import ( "testing" "git.ctrlz.es/mgdelacroix/craban/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) } func TestDeleteUsername(t *testing.T) { th, teardown := NewTestHelper(t) defer teardown() user := th.NewUser() gameName := "awesome game" game, err := th.store.Game().Create(gameName, user.ID) require.NoError(t, err) gameMember, err := th.store.Game().GetMember(game.ID, user.ID) require.NoError(t, err) require.NotZero(t, gameMember) // ToDo: implement member deletion /* err = th.store.User().DeleteByUsername(user.Username) require.NoError(t, err) _, err = th.store.Game().GetMember(game.ID, user.ID) require.Error(t, err) */ }