Skip to content

Commit

Permalink
add Test for GetUserIDsByNames
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Nov 9, 2019
1 parent 7c721df commit 763ba49
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions models/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,16 @@ func TestCreateUser_Issue5882(t *testing.T) {
assert.NoError(t, DeleteUser(v.user))
}
}

func TestGetUserIDsByNames(t *testing.T) {

//ignore non existing
IDs, err := GetUserIDsByNames([]string{"user1", "user2", "do_not_exist"}, true)
assert.NoError(t, err)
assert.Equal(t, []int64{1, 2}, IDs)

//ignore non existing
IDs, err = GetUserIDsByNames([]string{"user1", "do_not_exist"}, false)
assert.Error(t, err)
assert.Equal(t, []int64{}, IDs)
}

0 comments on commit 763ba49

Please sign in to comment.