test: started internal/db test cases

- we use github.com/bitcomplete/sqltestutil to spin up a postgresql
container to test against
- minor error variable refactoring
This commit is contained in:
2023-11-21 13:58:59 -06:00
parent 459b71a109
commit f95cc2cae7
6 changed files with 167 additions and 10 deletions

View File

@@ -81,7 +81,7 @@ func (server *LoginServer) Login(peer *protocol.CNPeer, pkt protocol.Packet) err
// attempt login
account, err := server.dbHndlr.TryLogin(loginPkt.SzID, loginPkt.SzPassword)
if err == db.LoginErrorInvalidID {
if err == db.ErrLoginInvalidID {
// this is the default behavior, auto create the account if the ID isn't in use
account, err = server.dbHndlr.NewAccount(loginPkt.SzID, loginPkt.SzPassword)
if err != nil {
@@ -89,7 +89,7 @@ func (server *LoginServer) Login(peer *protocol.CNPeer, pkt protocol.Packet) err
SendError(LOGIN_DATABASE_ERROR)
return err
}
} else if err == db.LoginErrorInvalidPassword {
} else if err == db.ErrLoginInvalidPassword {
// respond with invalid password
SendError(LOGIN_ID_AND_PASSWORD_DO_NOT_MATCH)
return nil