Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Akamu
Game Server Go
Commits
0a753cd8
Commit
0a753cd8
authored
Dec 17, 2020
by
MaxGranzow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mock implementation of user search for testing
parent
cc437bd2
Pipeline
#2216
passed with stage
in 4 minutes and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
test/user_test.go
test/user_test.go
+11
-0
No files found.
test/user_test.go
View file @
0a753cd8
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"fmt"
"fmt"
"net/http/httptest"
"net/http/httptest"
"strconv"
"strconv"
"strings"
"testing"
"testing"
"time"
"time"
...
@@ -139,6 +140,16 @@ func (mockUser) SelectByUsername(username string) ([]schemas.InfoUserSchema, err
...
@@ -139,6 +140,16 @@ func (mockUser) SelectByUsername(username string) ([]schemas.InfoUserSchema, err
return
nil
,
sql
.
ErrNoRows
return
nil
,
sql
.
ErrNoRows
}
}
func
(
mockUser
)
SelectByUsernameLike
(
username
string
)
([]
schemas
.
InfoUserSchema
,
error
)
{
var
users
[]
schemas
.
InfoUserSchema
for
_
,
u
:=
range
mockUsers
{
if
strings
.
HasPrefix
(
u
.
Username
,
username
)
{
users
=
append
(
users
,
schemas
.
InfoUserFromFullUser
(
u
))
}
}
return
users
,
nil
}
// Users with IDs 1-3 have authentication. Everyone else will be rejected.
// Users with IDs 1-3 have authentication. Everyone else will be rejected.
func
(
mockUser
)
Authenticate
(
name
string
,
password
string
)
(
uint32
,
error
)
{
func
(
mockUser
)
Authenticate
(
name
string
,
password
string
)
(
uint32
,
error
)
{
if
correctpassword
,
ok
:=
mockUserPasswords
[
name
];
ok
&&
password
==
correctpassword
{
if
correctpassword
,
ok
:=
mockUserPasswords
[
name
];
ok
&&
password
==
correctpassword
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment