1
0

Integration tests (#71)

This commit is contained in:
konrad
2019-04-21 18:18:17 +00:00
committed by Gitea
parent 46efcb1005
commit 3872d1d8a7
69 changed files with 3924 additions and 136 deletions

View File

@ -247,6 +247,48 @@ func IsErrEmailNotConfirmed(err error) bool {
return ok
}
// ErrEmptyNewPassword represents a "EmptyNewPassword" kind of error.
type ErrEmptyNewPassword struct{}
// IsErrEmptyNewPassword checks if an error is a ErrEmptyNewPassword.
func IsErrEmptyNewPassword(err error) bool {
_, ok := err.(ErrEmptyNewPassword)
return ok
}
func (err ErrEmptyNewPassword) Error() string {
return fmt.Sprintf("New password is empty")
}
// ErrCodeEmptyNewPassword holds the unique world-error code of this error
const ErrCodeEmptyNewPassword = 1013
// HTTPError holds the http error description
func (err ErrEmptyNewPassword) HTTPError() web.HTTPError {
return web.HTTPError{HTTPCode: http.StatusPreconditionFailed, Code: ErrCodeEmptyNewPassword, Message: "Please specify new password."}
}
// ErrEmptyOldPassword represents a "EmptyOldPassword" kind of error.
type ErrEmptyOldPassword struct{}
// IsErrEmptyOldPassword checks if an error is a ErrEmptyOldPassword.
func IsErrEmptyOldPassword(err error) bool {
_, ok := err.(ErrEmptyOldPassword)
return ok
}
func (err ErrEmptyOldPassword) Error() string {
return fmt.Sprintf("Old password is empty")
}
// ErrCodeEmptyOldPassword holds the unique world-error code of this error
const ErrCodeEmptyOldPassword = 1014
// HTTPError holds the http error description
func (err ErrEmptyOldPassword) HTTPError() web.HTTPError {
return web.HTTPError{HTTPCode: http.StatusPreconditionFailed, Code: ErrCodeEmptyOldPassword, Message: "Please specify old password."}
}
// ===================
// Empty things errors
// ===================
@ -502,6 +544,33 @@ func (err ErrNoRightToSeeTask) HTTPError() web.HTTPError {
}
}
// ErrParentTaskCannotBeTheSame represents an error where the user tries to set a tasks parent as the same
type ErrParentTaskCannotBeTheSame struct {
TaskID int64
}
// IsErrParentTaskCannotBeTheSame checks if an error is ErrParentTaskCannotBeTheSame.
func IsErrParentTaskCannotBeTheSame(err error) bool {
_, ok := err.(ErrParentTaskCannotBeTheSame)
return ok
}
func (err ErrParentTaskCannotBeTheSame) Error() string {
return fmt.Sprintf("Tried to set a parents task as the same [TaskID: %v]", err.TaskID)
}
// ErrCodeParentTaskCannotBeTheSame holds the unique world-error code of this error
const ErrCodeParentTaskCannotBeTheSame = 4006
// HTTPError holds the http error description
func (err ErrParentTaskCannotBeTheSame) HTTPError() web.HTTPError {
return web.HTTPError{
HTTPCode: http.StatusForbidden,
Code: ErrCodeParentTaskCannotBeTheSame,
Message: "You cannot set a parent task to the task itself.",
}
}
// =================
// Namespace errors
// =================

View File

@ -38,3 +38,99 @@
namespace_id: 5
updated: 0
created: 0
-
id: 6
title: Test6
description: Lorem Ipsum
owner_id: 6
namespace_id: 6
updated: 0
created: 0
-
id: 7
title: Test7
description: Lorem Ipsum
owner_id: 6
namespace_id: 6
updated: 0
created: 0
-
id: 8
title: Test8
description: Lorem Ipsum
owner_id: 6
namespace_id: 6
updated: 0
created: 0
-
id: 9
title: Test9
description: Lorem Ipsum
owner_id: 6
namespace_id: 6
updated: 0
created: 0
-
id: 10
title: Test10
description: Lorem Ipsum
owner_id: 6
namespace_id: 6
updated: 0
created: 0
-
id: 11
title: Test11
description: Lorem Ipsum
owner_id: 6
namespace_id: 6
updated: 0
created: 0
-
id: 12
title: Test12
description: Lorem Ipsum
owner_id: 6
namespace_id: 7
updated: 0
created: 0
-
id: 13
title: Test13
description: Lorem Ipsum
owner_id: 6
namespace_id: 8
updated: 0
created: 0
-
id: 14
title: Test14
description: Lorem Ipsum
owner_id: 6
namespace_id: 9
updated: 0
created: 0
-
id: 15
title: Test15
description: Lorem Ipsum
owner_id: 6
namespace_id: 10
updated: 0
created: 0
-
id: 16
title: Test16
description: Lorem Ipsum
owner_id: 6
namespace_id: 11
updated: 0
created: 0
-
id: 17
title: Test17
description: Lorem Ipsum
owner_id: 6
namespace_id: 12
updated: 0
created: 0

View File

@ -1,21 +1,60 @@
-
id: 1
- id: 1
name: testnamespace
description: Lorem Ipsum
owner_id: 1
updated: 0
created: 0
-
id: 2
- id: 2
name: testnamespace2
description: Lorem Ipsum
owner_id: 2
updated: 0
created: 0
-
id: 3
- id: 3
name: testnamespace3
description: Lorem Ipsum
owner_id: 3
updated: 0
created: 0
- id: 6
name: testnamespace6
description: Lorem Ipsum
owner_id: 6
updated: 0
created: 0
- id: 7
name: testnamespace7
description: Lorem Ipsum
owner_id: 6
updated: 0
created: 0
- id: 8
name: testnamespace8
description: Lorem Ipsum
owner_id: 6
updated: 0
created: 0
- id: 9
name: testnamespace9
description: Lorem Ipsum
owner_id: 6
updated: 0
created: 0
- id: 10
name: testnamespace10
description: Lorem Ipsum
owner_id: 6
updated: 0
created: 0
- id: 11
name: testnamespace11
description: Lorem Ipsum
owner_id: 6
updated: 0
created: 0
- id: 12
name: testnamespace12
description: Lorem Ipsum
owner_id: 6
updated: 0
created: 0

View File

@ -0,0 +1,8 @@
- id: 1
task_id: 30
user_id: 1
created: 0
- id: 2
task_id: 30
user_id: 2
created: 0

View File

@ -1,5 +1,6 @@
- id: 1
text: 'task #1'
description: 'Lorem Ipsum'
created_by_id: 1
list_id: 1
created: 1543626724
@ -90,4 +91,105 @@
created_by_id: 5
list_id: 5
created: 1543626724
updated: 1543626724
updated: 1543626724
- id: 15
text: 'task #15'
created_by_id: 6
list_id: 6
created: 1543626724
updated: 1543626724
- id: 16
text: 'task #16'
created_by_id: 6
list_id: 7
created: 1543626724
updated: 1543626724
- id: 17
text: 'task #17'
created_by_id: 6
list_id: 8
created: 1543626724
updated: 1543626724
- id: 18
text: 'task #18'
created_by_id: 6
list_id: 9
created: 1543626724
updated: 1543626724
- id: 19
text: 'task #19'
created_by_id: 6
list_id: 10
created: 1543626724
updated: 1543626724
- id: 20
text: 'task #20'
created_by_id: 6
list_id: 11
created: 1543626724
updated: 1543626724
- id: 21
text: 'task #21'
created_by_id: 6
list_id: 12
created: 1543626724
updated: 1543626724
- id: 22
text: 'task #22'
created_by_id: 6
list_id: 13
created: 1543626724
updated: 1543626724
- id: 23
text: 'task #23'
created_by_id: 6
list_id: 14
created: 1543626724
updated: 1543626724
- id: 24
text: 'task #24'
created_by_id: 6
list_id: 15
created: 1543626724
updated: 1543626724
- id: 25
text: 'task #25'
created_by_id: 6
list_id: 16
created: 1543626724
updated: 1543626724
- id: 26
text: 'task #26'
created_by_id: 6
list_id: 17
created: 1543626724
updated: 1543626724
- id: 27
text: 'task #27 with reminders'
created_by_id: 1
reminders_unix: '[1543626724,1543626824]'
list_id: 1
created: 1543626724
updated: 1543626724
- id: 28
text: 'task #28 with repeat after'
done: false
created_by_id: 1
repeat_after: 3600
list_id: 1
created: 1543626724
updated: 1543626724
- id: 29
text: 'task #29 with parent task (1)'
created_by_id: 1
parent_task_id: 1
list_id: 1
created: 1543626724
updated: 1543626724
- id: 30
text: 'task #30 with assignees'
created_by_id: 1
list_id: 1
created: 1543626724
updated: 1543626724

View File

@ -1,10 +1,30 @@
- id: 1
team_id: 1
list_id: 3
right: 0
updated: 0
created: 0
# This team has read only access on list 6
- id: 2
team_id: 2
list_id: 3
list_id: 6
right: 0
updated: 0
created: 0
# This team has write access on list 7
- id: 3
team_id: 3
list_id: 7
right: 1
updated: 0
created: 0
# This team has admin access on list 8
- id: 4
team_id: 4
list_id: 8
right: 2
updated: 0
created: 0

View File

@ -7,3 +7,27 @@
team_id: 1
user_id: 2
created: 0
-
team_id: 2
user_id: 1
created: 0
-
team_id: 3
user_id: 1
created: 0
-
team_id: 4
user_id: 1
created: 0
-
team_id: 5
user_id: 1
created: 0
-
team_id: 6
user_id: 1
created: 0
-
team_id: 7
user_id: 1
created: 0

View File

@ -1,10 +1,34 @@
- id: 1
team_id: 1
namespace_id: 3
right: 0
updated: 0
created: 0
- id: 2
team_id: 2
namespace_id: 3
right: 0
updated: 0
created: 0
- id: 3
team_id: 5
namespace_id: 7
right: 0
updated: 0
created: 0
- id: 4
team_id: 6
namespace_id: 8
right: 1
updated: 0
created: 0
- id: 5
team_id: 7
namespace_id: 9
right: 2
updated: 0
created: 0

View File

@ -1,5 +1,22 @@
-
id: 1
- id: 1
name: testteam1
description: Lorem Ipsum
created_by_id: 1
- id: 2
name: testteam2_read_only_on_list6
created_by_id: 1
- id: 3
name: testteam3_write_on_list7
created_by_id: 1
- id: 4
name: testteam4_admin_on_list8
created_by_id: 1
- id: 5
name: testteam2_read_only_on_namespace7
created_by_id: 1
- id: 6
name: testteam3_write_on_namespace8
created_by_id: 1
- id: 7
name: testteam4_admin_on_namespace9
created_by_id: 1

View File

@ -1,28 +1,30 @@
-
id: 1
username: 'user1'
password: '1234'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user1@example.com'
is_active: true
updated: 0
created: 0
-
id: 2
username: 'user2'
password: '1234'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user2@example.com'
updated: 0
created: 0
-
id: 3
username: 'user3'
password: '1234'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user3@example.com'
password_reset_token: passwordresettesttoken
updated: 0
created: 0
-
id: 4
username: 'user4'
password: '1234'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user4@example.com'
email_confirm_token: tiepiQueed8ahc7zeeFe1eveiy4Ein8osooxegiephauph2Ael
updated: 0
@ -30,9 +32,17 @@
-
id: 5
username: 'user5'
password: '1234'
email: 'user4@example.com'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user5@example.com'
email_confirm_token: tiepiQueed8ahc7zeeFe1eveiy4Ein8osooxegiephauph2Ael
is_active: false
updated: 0
created: 0
# This use is used to create a whole bunch of lists which are then shared directly with a user
- id: 6
username: 'user6'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user6@example.com'
is_active: true
updated: 0
created: 0

View File

@ -1,10 +1,34 @@
- id: 1
user_id: 1
list_id: 3
right: 0
updated: 0
created: 0
- id: 2
user_id: 2
list_id: 3
right: 0
updated: 0
created: 0
- id: 3
user_id: 1
list_id: 9
right: 0
updated: 0
created: 0
- id: 4
user_id: 1
list_id: 10
right: 1
updated: 0
created: 0
- id: 5
user_id: 1
list_id: 11
right: 2
updated: 0
created: 0

View File

@ -1,10 +1,34 @@
- id: 1
user_id: 1
namespace_id: 3
right: 0
updated: 0
created: 0
- id: 2
user_id: 2
namespace_id: 3
right: 0
updated: 0
created: 0
- id: 3
user_id: 1
namespace_id: 10
right: 0
updated: 0
created: 0
- id: 4
user_id: 1
namespace_id: 11
right: 1
updated: 0
created: 0
- id: 5
user_id: 1
namespace_id: 12
right: 2
updated: 0
created: 0

View File

@ -1,6 +1,7 @@
package models
import (
"gopkg.in/d4l3k/messagediff.v1"
"reflect"
"runtime"
"testing"
@ -48,7 +49,7 @@ func TestLabelTask_ReadAll(t *testing.T) {
CreatedBy: &User{
ID: 2,
Username: "user2",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
},
},
},
@ -95,8 +96,8 @@ func TestLabelTask_ReadAll(t *testing.T) {
if (err != nil) && tt.wantErr && !tt.errType(err) {
t.Errorf("LabelTask.ReadAll() Wrong error type! Error = %v, want = %v", err, runtime.FuncForPC(reflect.ValueOf(tt.errType).Pointer()).Name())
}
if !reflect.DeepEqual(gotLabels, tt.wantLabels) {
t.Errorf("LabelTask.ReadAll() = %v, want %v", gotLabels, tt.wantLabels)
if diff, equal := messagediff.PrettyDiff(gotLabels, tt.wantLabels); !equal {
t.Errorf("LabelTask.ReadAll() = %v, want %v, diff: %v", l, tt.wantLabels, diff)
}
})
}

View File

@ -17,6 +17,7 @@
package models
import (
"gopkg.in/d4l3k/messagediff.v1"
"reflect"
"runtime"
"testing"
@ -45,7 +46,8 @@ func TestLabel_ReadAll(t *testing.T) {
user1 := &User{
ID: 1,
Username: "user1",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
IsActive: true,
}
tests := []struct {
name string
@ -85,7 +87,7 @@ func TestLabel_ReadAll(t *testing.T) {
CreatedBy: &User{
ID: 2,
Username: "user2",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
},
},
},
@ -115,8 +117,8 @@ func TestLabel_ReadAll(t *testing.T) {
t.Errorf("Label.ReadAll() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotLs, tt.wantLs) {
t.Errorf("Label.ReadAll() = %v, want %v", gotLs, tt.wantLs)
if diff, equal := messagediff.PrettyDiff(gotLs, tt.wantLs); !equal {
t.Errorf("Label.ReadAll() = %v, want %v, diff: %v", gotLs, tt.wantLs, diff)
}
})
}
@ -138,7 +140,8 @@ func TestLabel_ReadOne(t *testing.T) {
user1 := &User{
ID: 1,
Username: "user1",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
IsActive: true,
}
tests := []struct {
name string
@ -192,7 +195,7 @@ func TestLabel_ReadOne(t *testing.T) {
CreatedBy: &User{
ID: 2,
Username: "user2",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
},
},
auth: &User{ID: 1},
@ -224,8 +227,8 @@ func TestLabel_ReadOne(t *testing.T) {
if (err != nil) && tt.wantErr && !tt.errType(err) {
t.Errorf("Label.ReadOne() Wrong error type! Error = %v, want = %v", err, runtime.FuncForPC(reflect.ValueOf(tt.errType).Pointer()).Name())
}
if !reflect.DeepEqual(l, tt.want) && !tt.wantErr && !tt.wantForbidden {
t.Errorf("Label.ReadOne() = %v, want %v", l, tt.want)
if diff, equal := messagediff.PrettyDiff(l, tt.want); !equal && !tt.wantErr && !tt.wantForbidden {
t.Errorf("Label.ReadAll() = %v, want %v, diff: %v", l, tt.want, diff)
}
})
}

View File

@ -23,7 +23,7 @@ import (
func TestList_Create(t *testing.T) {
// Create test database
//assert.NoError(t, PrepareTestDatabase())
//assert.NoError(t, LoadFixtures())
// Get our doer
doer, err := GetUserByID(1)
@ -78,17 +78,6 @@ func TestList_Create(t *testing.T) {
assert.Error(t, err)
assert.True(t, IsErrListDoesNotExist(err))
// Delete a nonexistant list
err = dummylist.Delete()
assert.Error(t, err)
assert.True(t, IsErrListDoesNotExist(err))
// Check failing with no title
list2 := List{}
err = list2.Create(&doer)
assert.Error(t, err)
assert.True(t, IsErrListTitleCannotBeEmpty(err))
// Check creation with a nonexistant namespace
list3 := List{
Title: "test",

View File

@ -24,11 +24,6 @@ import (
// CreateOrUpdateList updates a list or creates it if it doesn't exist
func CreateOrUpdateList(list *List) (err error) {
// Check we have at least a title
if list.Title == "" {
return ErrListTitleCannotBeEmpty{}
}
// Check if the namespace exists
if list.NamespaceID != 0 {
_, err = GetNamespaceByID(list.NamespaceID)
@ -73,11 +68,6 @@ func CreateOrUpdateList(list *List) (err error) {
// @Failure 500 {object} models.Message "Internal error"
// @Router /lists/{id} [post]
func (l *List) Update() (err error) {
// Check if it exists
lorig := List{ID: l.ID}
if err = lorig.GetSimpleByID(); err != nil {
return
}
return CreateOrUpdateList(l)
}

View File

@ -34,10 +34,6 @@ import (
// @Failure 500 {object} models.Message "Internal error"
// @Router /lists/{id} [delete]
func (l *List) Delete() (err error) {
// Check if the list exists
if err = l.GetSimpleByID(); err != nil {
return
}
// Delete the list
_, err = x.ID(l.ID).Delete(&List{})

View File

@ -24,7 +24,7 @@ import (
func TestList_ReadAll(t *testing.T) {
// Create test database
//assert.NoError(t, PrepareTestDatabase())
//assert.NoError(t, LoadFixtures())
// Get all lists for our namespace
lists, err := GetListsByNamespaceID(1, &User{})
@ -40,7 +40,7 @@ func TestList_ReadAll(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, reflect.TypeOf(lists3).Kind(), reflect.Slice)
s := reflect.ValueOf(lists3)
assert.Equal(t, s.Len(), 3)
assert.Equal(t, 15, s.Len())
// Try getting lists for a nonexistant user
_, err = lists2.ReadAll("", &User{ID: 984234}, 1)

View File

@ -59,6 +59,7 @@ func (t *ListTask) updateTaskAssignees(assignees []*User) (err error) {
if len(assignees) == 0 && len(t.Assignees) > 0 {
_, err = x.Where("task_id = ?", t.ID).
Delete(ListTaskAssginee{})
t.setTaskAssignees(assignees)
return err
}
@ -123,9 +124,19 @@ func (t *ListTask) updateTaskAssignees(assignees []*User) (err error) {
}
}
t.setTaskAssignees(assignees)
return
}
// Small helper functions to set the new assignees in various places
func (t *ListTask) setTaskAssignees(assignees []*User) {
if len(assignees) == 0 {
t.Assignees = nil
return
}
t.Assignees = assignees
}
// Delete a task assignee
// @Summary Delete an assignee
// @Description Un-assign a user from a task.

View File

@ -32,8 +32,8 @@ const (
// @Param p query int false "The page number. Used for pagination. If not provided, the first page of results is returned."
// @Param s query string false "Search tasks by task text."
// @Param sort query string false "The sorting parameter. Possible values to sort by are priority, prioritydesc, priorityasc, dueadate, dueadatedesc, dueadateasc."
// @Param startdate query int false "The start date parameter to filter by. Expects a unix timestamp."
// @Param enddate query int false "The end date parameter to filter by. Expects a unix timestamp."
// @Param startdate query int false "The start date parameter to filter by. Expects a unix timestamp. If no end date, but a start date is specified, the end date is set to the current time."
// @Param enddate query int false "The end date parameter to filter by. Expects a unix timestamp. If no start date, but an end date is specified, the start date is set to the current time."
// @Security JWTKeyAuth
// @Success 200 {array} models.List "The tasks"
// @Failure 500 {object} models.Message "Internal error"

View File

@ -7,9 +7,8 @@
package models
import (
"fmt"
"github.com/stretchr/testify/assert"
"reflect"
"gopkg.in/d4l3k/messagediff.v1"
"sort"
"testing"
@ -21,6 +20,7 @@ func sortTasksForTesting(by SortBy) (tasks []*ListTask) {
{
ID: 1,
Text: "task #1",
Description: "Lorem Ipsum",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
@ -123,6 +123,128 @@ func sortTasksForTesting(by SortBy) (tasks []*ListTask) {
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 15,
Text: "task #15",
CreatedByID: 6,
ListID: 6,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 16,
Text: "task #16",
CreatedByID: 6,
ListID: 7,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 17,
Text: "task #17",
CreatedByID: 6,
ListID: 8,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 18,
Text: "task #18",
CreatedByID: 6,
ListID: 9,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 19,
Text: "task #19",
CreatedByID: 6,
ListID: 10,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 20,
Text: "task #20",
CreatedByID: 6,
ListID: 11,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 21,
Text: "task #21",
CreatedByID: 6,
ListID: 12,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 22,
Text: "task #22",
CreatedByID: 6,
ListID: 13,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 23,
Text: "task #23",
CreatedByID: 6,
ListID: 14,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 24,
Text: "task #24",
CreatedByID: 6,
ListID: 15,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 25,
Text: "task #25",
CreatedByID: 6,
ListID: 16,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 26,
Text: "task #26",
CreatedByID: 6,
ListID: 17,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 27,
Text: "task #27 with reminders",
CreatedByID: 1,
RemindersUnix: []int64{1543626724, 1543626824},
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 28,
Text: "task #28 with repeat after",
CreatedByID: 1,
ListID: 1,
RepeatAfter: 3600,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 30,
Text: "task #30 with assignees",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
}
switch by {
@ -138,6 +260,10 @@ func sortTasksForTesting(by SortBy) (tasks []*ListTask) {
sort.Slice(tasks, func(i, j int) bool {
return tasks[i].DueDateUnix > tasks[j].DueDateUnix
})
// Swap since sqlite seems to sort differently
tmp := tasks[5]
tasks[5] = tasks[3]
tasks[3] = tmp
case SortTasksByDueDateAsc:
sort.Slice(tasks, func(i, j int) bool {
return tasks[i].DueDateUnix < tasks[j].DueDateUnix
@ -148,7 +274,7 @@ func sortTasksForTesting(by SortBy) (tasks []*ListTask) {
}
func TestListTask_ReadAll(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
assert.NoError(t, LoadFixtures())
type fields struct {
ID int64
Text string
@ -221,6 +347,7 @@ func TestListTask_ReadAll(t *testing.T) {
{
ID: 1,
Text: "task #1",
Description: "Lorem Ipsum",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
@ -304,6 +431,127 @@ func TestListTask_ReadAll(t *testing.T) {
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
}, {
ID: 15,
Text: "task #15",
CreatedByID: 6,
ListID: 6,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 16,
Text: "task #16",
CreatedByID: 6,
ListID: 7,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 17,
Text: "task #17",
CreatedByID: 6,
ListID: 8,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 18,
Text: "task #18",
CreatedByID: 6,
ListID: 9,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 19,
Text: "task #19",
CreatedByID: 6,
ListID: 10,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 20,
Text: "task #20",
CreatedByID: 6,
ListID: 11,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 21,
Text: "task #21",
CreatedByID: 6,
ListID: 12,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 22,
Text: "task #22",
CreatedByID: 6,
ListID: 13,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 23,
Text: "task #23",
CreatedByID: 6,
ListID: 14,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 24,
Text: "task #24",
CreatedByID: 6,
ListID: 15,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 25,
Text: "task #25",
CreatedByID: 6,
ListID: 16,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 26,
Text: "task #26",
CreatedByID: 6,
ListID: 17,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 27,
Text: "task #27 with reminders",
CreatedByID: 1,
RemindersUnix: []int64{1543626724, 1543626824},
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 28,
Text: "task #28 with repeat after",
CreatedByID: 1,
ListID: 1,
RepeatAfter: 3600,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 30,
Text: "task #30 with assignees",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 4,
@ -349,23 +597,29 @@ func TestListTask_ReadAll(t *testing.T) {
a: &User{ID: 1},
page: 0,
},
want: sortTasksForTesting(SortTasksByDueDateDesc),
wantErr: false,
},
{
name: "ReadAll ListTasks sorted by due date asc",
fields: fields{
Sorting: "duedateasc",
},
args: args{
search: "",
a: &User{ID: 1},
page: 0,
},
want: []*ListTask{
{
ID: 5,
Text: "task #5 higher due date",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
DueDateUnix: 1543636724,
},
{
ID: 6,
Text: "task #6 lower due date",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
DueDateUnix: 1543616724,
},
{
ID: 1,
Text: "task #1",
Description: "Lorem Ipsum",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
@ -450,6 +704,352 @@ func TestListTask_ReadAll(t *testing.T) {
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 15,
Text: "task #15",
CreatedByID: 6,
ListID: 6,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 16,
Text: "task #16",
CreatedByID: 6,
ListID: 7,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 17,
Text: "task #17",
CreatedByID: 6,
ListID: 8,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 18,
Text: "task #18",
CreatedByID: 6,
ListID: 9,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 19,
Text: "task #19",
CreatedByID: 6,
ListID: 10,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 20,
Text: "task #20",
CreatedByID: 6,
ListID: 11,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 21,
Text: "task #21",
CreatedByID: 6,
ListID: 12,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 22,
Text: "task #22",
CreatedByID: 6,
ListID: 13,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 23,
Text: "task #23",
CreatedByID: 6,
ListID: 14,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 24,
Text: "task #24",
CreatedByID: 6,
ListID: 15,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 25,
Text: "task #25",
CreatedByID: 6,
ListID: 16,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 26,
Text: "task #26",
CreatedByID: 6,
ListID: 17,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 27,
Text: "task #27 with reminders",
CreatedByID: 1,
RemindersUnix: []int64{1543626724, 1543626824},
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 28,
Text: "task #28 with repeat after",
CreatedByID: 1,
ListID: 1,
RepeatAfter: 3600,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 30,
Text: "task #30 with assignees",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
},
wantErr: false,
},
{
name: "ReadAll ListTasks sorted by due date asc",
fields: fields{
Sorting: "duedateasc",
},
args: args{
search: "",
a: &User{ID: 1},
page: 0,
},
want: []*ListTask{
{
ID: 1,
Text: "task #1",
Description: "Lorem Ipsum",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 2,
Text: "task #2 done",
Done: true,
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 3,
Text: "task #3 high prio",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
Priority: 100,
},
{
ID: 4,
Text: "task #4 low prio",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
Priority: 1,
},
{
ID: 7,
Text: "task #7 with start date",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
StartDateUnix: 1544600000,
},
{
ID: 8,
Text: "task #8 with end date",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
EndDateUnix: 1544700000,
},
{
ID: 9,
Text: "task #9 with start and end date",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
StartDateUnix: 1544600000,
EndDateUnix: 1544700000,
},
{
ID: 10,
Text: "task #10 basic",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 11,
Text: "task #11 basic",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 12,
Text: "task #12 basic",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 15,
Text: "task #15",
CreatedByID: 6,
ListID: 6,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 16,
Text: "task #16",
CreatedByID: 6,
ListID: 7,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 17,
Text: "task #17",
CreatedByID: 6,
ListID: 8,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 18,
Text: "task #18",
CreatedByID: 6,
ListID: 9,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 19,
Text: "task #19",
CreatedByID: 6,
ListID: 10,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 20,
Text: "task #20",
CreatedByID: 6,
ListID: 11,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 21,
Text: "task #21",
CreatedByID: 6,
ListID: 12,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 22,
Text: "task #22",
CreatedByID: 6,
ListID: 13,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 23,
Text: "task #23",
CreatedByID: 6,
ListID: 14,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 24,
Text: "task #24",
CreatedByID: 6,
ListID: 15,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 25,
Text: "task #25",
CreatedByID: 6,
ListID: 16,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 26,
Text: "task #26",
CreatedByID: 6,
ListID: 17,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 27,
Text: "task #27 with reminders",
CreatedByID: 1,
RemindersUnix: []int64{1543626724, 1543626824},
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 28,
Text: "task #28 with repeat after",
CreatedByID: 1,
ListID: 1,
RepeatAfter: 3600,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 30,
Text: "task #30 with assignees",
CreatedByID: 1,
ListID: 1,
Created: 1543626724,
Updated: 1543626724,
},
{
ID: 6,
Text: "task #6 lower due date",
@ -481,6 +1081,7 @@ func TestListTask_ReadAll(t *testing.T) {
a: &User{ID: 1},
page: 0,
},
want: sortTasksForTesting(SortTasksByDueDateDesc),
wantErr: false,
},
@ -612,25 +1213,11 @@ func TestListTask_ReadAll(t *testing.T) {
}
got, err := lt.ReadAll(tt.args.search, tt.args.a, tt.args.page)
if (err != nil) != tt.wantErr {
t.Errorf("ListTask.ReadAll() error = %v, wantErr %v", err, tt.wantErr)
t.Errorf("Test %s, ListTask.ReadAll() error = %v, wantErr %v", tt.name, err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("ListTask.ReadAll() = %v, want %v", got, tt.want)
fmt.Println("Got:")
gotslice := got.([]*ListTask)
for _, g := range gotslice {
fmt.Println(g.Text)
//fmt.Println(g.StartDateUnix)
//fmt.Println(g.EndDateUnix)
}
fmt.Println("Want:")
wantslice := tt.want.([]*ListTask)
for _, w := range wantslice {
fmt.Println(w.Text)
//fmt.Println(w.StartDateUnix)
//fmt.Println(w.EndDateUnix)
}
if diff, equal := messagediff.PrettyDiff(got, tt.want); !equal {
t.Errorf("Test %s, LabelTask.ReadAll() = %v, want %v, diff: %v", tt.name, got, tt.want, diff)
}
})
}

View File

@ -96,6 +96,11 @@ func (t *ListTask) Update() (err error) {
return
}
// Parent task cannot be the same as the current task
if t.ID == t.ParentTaskID {
return ErrParentTaskCannotBeTheSame{TaskID: t.ID}
}
// When a repeating task is marked as done, we update all deadlines and reminders and set it as undone
updateDone(&ot, t)
@ -128,15 +133,46 @@ func (t *ListTask) Update() (err error) {
return err
}
// And because a false is considered to be a null value, we need to explicitly check that case here.
//////
// Mergo does ignore nil values. Because of that, we need to check all parameters and set the updated to
// nil/their nil value in the struct which is inserted.
////
// Done
if !t.Done {
ot.Done = false
}
// If the priority is 0, we also need to explicitly check that here
// Priority
if t.Priority == 0 {
ot.Priority = 0
}
// Description
if t.Description == "" {
ot.Description = ""
}
// Due date
if t.DueDateUnix == 0 {
ot.DueDateUnix = 0
}
// Reminders
if len(t.RemindersUnix) == 0 {
ot.RemindersUnix = nil
}
// Repeat after
if t.RepeatAfter == 0 {
ot.RepeatAfter = 0
}
// Parent task
if t.ParentTaskID == 0 {
ot.ParentTaskID = 0
}
// Start date
if t.StartDateUnix == 0 {
ot.StartDateUnix = 0
}
// End date
if t.EndDateUnix == 0 {
ot.EndDateUnix = 0
}
_, err = x.ID(t.ID).
Cols("text",

View File

@ -41,6 +41,7 @@ func (t *ListTask) CanCreate(a web.Auth) (bool, error) {
// CanRead determines if a user can read a task
func (t *ListTask) CanRead(a web.Auth) (canRead bool, err error) {
//return t.canDoListTask(a)
// Get the task, error out if it doesn't exist
*t, err = getTaskByIDSimple(t.ID)
if err != nil {

View File

@ -22,7 +22,7 @@ import (
)
func TestListTask_Create(t *testing.T) {
//assert.NoError(t, PrepareTestDatabase())
//assert.NoError(t, LoadFixtures())
// Fake list task
listtask := ListTask{

View File

@ -27,7 +27,7 @@ type ListUser struct {
// The list id.
ListID int64 `xorm:"int(11) not null INDEX" json:"-" param:"list"`
// The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX null" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A unix timestamp when this relation was created. You cannot change this value.
Created int64 `xorm:"created not null" json:"created"`

View File

@ -17,6 +17,7 @@
package models
import (
"gopkg.in/d4l3k/messagediff.v1"
"reflect"
"runtime"
"testing"
@ -159,7 +160,8 @@ func TestListUser_ReadAll(t *testing.T) {
User: User{
ID: 1,
Username: "user1",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
IsActive: true,
},
Right: RightRead,
},
@ -167,7 +169,7 @@ func TestListUser_ReadAll(t *testing.T) {
User: User{
ID: 2,
Username: "user2",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
},
Right: RightRead,
},
@ -204,8 +206,8 @@ func TestListUser_ReadAll(t *testing.T) {
if (err != nil) && tt.wantErr && !tt.errType(err) {
t.Errorf("ListUser.ReadAll() Wrong error type! Error = %v, want = %v", err, runtime.FuncForPC(reflect.ValueOf(tt.errType).Pointer()).Name())
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("ListUser.ReadAll() = %v, want %v", got, tt.want)
if diff, equal := messagediff.PrettyDiff(got, tt.want); !equal {
t.Errorf("ListUser.ReadAll() = %v, want %v, diff: %v", got, tt.want, diff)
}
})
}

View File

@ -24,7 +24,7 @@ import (
func TestNamespace_Create(t *testing.T) {
// Create test database
//assert.NoError(t, PrepareTestDatabase())
//assert.NoError(t, LoadFixtures())
// Dummy namespace
dummynamespace := Namespace{
@ -122,5 +122,5 @@ func TestNamespace_Create(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, reflect.TypeOf(nsps).Kind(), reflect.Slice)
s := reflect.ValueOf(nsps)
assert.Equal(t, 3, s.Len())
assert.Equal(t, 9, s.Len())
}

View File

@ -27,7 +27,7 @@ type NamespaceUser struct {
// The namespace id
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"-" param:"namespace"`
// The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX null" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A unix timestamp when this relation was created. You cannot change this value.
Created int64 `xorm:"created not null" json:"created"`

View File

@ -20,6 +20,7 @@ package models
import (
"code.vikunja.io/web"
"gopkg.in/d4l3k/messagediff.v1"
"reflect"
"runtime"
"testing"
@ -160,7 +161,8 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
User: User{
ID: 1,
Username: "user1",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
IsActive: true,
},
Right: RightRead,
},
@ -168,7 +170,7 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
User: User{
ID: 2,
Username: "user2",
Password: "1234",
Password: "$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.",
},
Right: RightRead,
},
@ -206,8 +208,8 @@ func TestNamespaceUser_ReadAll(t *testing.T) {
if (err != nil) && tt.wantErr && !tt.errType(err) {
t.Errorf("NamespaceUser.ReadAll() Wrong error type! Error = %v, want = %v", err, runtime.FuncForPC(reflect.ValueOf(tt.errType).Pointer()).Name())
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("NamespaceUser.ReadAll() = %v, want %v", got, tt.want)
if diff, equal := messagediff.PrettyDiff(got, tt.want); !equal {
t.Errorf("NamespaceUser.ReadAll() = %v, want %v, diff: %v", got, tt.want, diff)
}
})
}

View File

@ -27,7 +27,7 @@ type TeamList struct {
// The list id.
ListID int64 `xorm:"int(11) not null INDEX" json:"-" param:"list"`
// The right this team has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX null" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A unix timestamp when this relation was created. You cannot change this value.
Created int64 `xorm:"created not null" json:"created"`

View File

@ -88,7 +88,7 @@ func TestTeamList(t *testing.T) {
// Test read all for a list where the user not has access
tl6 := tl
tl6.ListID = 4
tl6.ListID = 5
_, err = tl6.ReadAll("", &u, 1)
assert.Error(t, err)
assert.True(t, IsErrNeedToHaveListReadAccess(err))

View File

@ -27,7 +27,7 @@ type TeamNamespace struct {
// The namespace id.
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"-" param:"namespace"`
// The right this team has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
Right Right `xorm:"int(11) INDEX null" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
// A unix timestamp when this relation was created. You cannot change this value.
Created int64 `xorm:"created not null" json:"created"`

View File

@ -59,7 +59,7 @@ func TestTeam_Create(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, reflect.TypeOf(ts).Kind(), reflect.Slice)
s := reflect.ValueOf(ts)
assert.Equal(t, 2, s.Len())
assert.Equal(t, 8, s.Len())
// Check inserting it with an empty name
dummyteam.Name = ""

View File

@ -33,6 +33,13 @@ import (
// MainTest creates the test engine
func MainTest(m *testing.M, pathToRoot string) {
SetupTests(pathToRoot)
os.Exit(m.Run())
}
// SetupTests takes care of seting up the db, fixtures etc.
// This is an extra function to be able to call the fixtures setup from the integration tests.
func SetupTests(pathToRoot string) {
var err error
fixturesDir := filepath.Join(pathToRoot, "pkg", "models", "fixtures")
if err = createTestEngine(fixturesDir); err != nil {
@ -43,11 +50,9 @@ func MainTest(m *testing.M, pathToRoot string) {
mail.StartMailDaemon()
// Create test database
if err = PrepareTestDatabase(); err != nil {
if err = LoadFixtures(); err != nil {
log.Log.Fatalf("Error preparing test database: %v", err.Error())
}
os.Exit(m.Run())
}
func createTestEngine(fixturesDir string) error {
@ -90,8 +95,3 @@ func createTestEngine(fixturesDir string) error {
return InitFixtures(fixturesHelper, fixturesDir)
}
// PrepareTestDatabase load test fixtures into test database
func PrepareTestDatabase() error {
return LoadFixtures()
}

View File

@ -30,7 +30,7 @@ func CreateUser(user User) (newUser User, err error) {
newUser = user
// Check if we have all needed informations
if newUser.Password == "" || newUser.Username == "" {
if newUser.Password == "" || newUser.Username == "" || newUser.Email == "" {
return User{}, ErrNoUsernamePassword{}
}
@ -154,6 +154,10 @@ func UpdateUser(user User) (updatedUser User, err error) {
// UpdateUserPassword updates the password of a user
func UpdateUserPassword(user *User, newPassword string) (err error) {
if newPassword == "" {
return ErrEmptyNewPassword{}
}
// Get all user details
theUser, err := GetUserByID(user.ID)
if err != nil {

View File

@ -83,6 +83,10 @@ type PasswordTokenRequest struct {
// RequestUserPasswordResetToken inserts a random token to reset a users password into the databsse
func RequestUserPasswordResetToken(tr *PasswordTokenRequest) (err error) {
if tr.Email == "" {
return ErrNoUsernamePassword{}
}
// Check if the user exists
user, err := GetUser(User{Email: tr.Email})
if err != nil {

View File

@ -24,7 +24,7 @@ import (
func TestCreateUser(t *testing.T) {
// Create test database
//assert.NoError(t, PrepareTestDatabase())
//assert.NoError(t, LoadFixtures())
// Get our doer
doer, err := GetUserByID(1)
@ -50,7 +50,7 @@ func TestCreateUser(t *testing.T) {
assert.Error(t, err)
// Check if it fails to create a user with just the same username
_, err = CreateUser(User{Username: dummyuser.Username, Password: "fsdf"})
_, err = CreateUser(User{Username: dummyuser.Username, Password: "12345", Email: "email@example.com"})
assert.Error(t, err)
assert.True(t, IsErrUsernameExists(err))