Commit 0a753cd8 authored by MaxGranzow's avatar MaxGranzow

Add mock implementation of user search for testing

parent cc437bd2
Pipeline #2216 passed with stage
in 4 minutes and 54 seconds
......@@ -7,6 +7,7 @@ import (
"fmt"
"net/http/httptest"
"strconv"
"strings"
"testing"
"time"
......@@ -139,6 +140,16 @@ func (mockUser) SelectByUsername(username string) ([]schemas.InfoUserSchema, err
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.
func (mockUser) Authenticate(name string, password string) (uint32, error) {
if correctpassword, ok := mockUserPasswords[name]; ok && password == correctpassword {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment