mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-26 07:33:21 -05:00
Test not allowing users to be re-created with the same username
This commit is contained in:
parent
85a58c3ff8
commit
af9371aeb9
@ -1,6 +1,7 @@
|
|||||||
package handlers_test
|
package handlers_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/aclindsa/moneygo/internal/handlers"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
@ -50,6 +51,24 @@ func TestCreateUser(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDontRecreateUser(t *testing.T) {
|
||||||
|
RunWith(t, &data[0], func(t *testing.T, d *TestData) {
|
||||||
|
for _, user := range data[0].users {
|
||||||
|
_, err := createUser(&user)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("Expected error re-creating user")
|
||||||
|
}
|
||||||
|
if herr, ok := err.(*handlers.Error); ok {
|
||||||
|
if herr.ErrorId != 4 { // User exists
|
||||||
|
t.Fatalf("Unexpected API error re-creating user: %s", herr)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
t.Fatalf("Expected error re-creating user")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetUser(t *testing.T) {
|
func TestGetUser(t *testing.T) {
|
||||||
RunWith(t, &data[0], func(t *testing.T, d *TestData) {
|
RunWith(t, &data[0], func(t *testing.T, d *TestData) {
|
||||||
u, err := getUser(d.clients[0], d.users[0].UserId)
|
u, err := getUser(d.clients[0], d.users[0].UserId)
|
||||||
|
Loading…
Reference in New Issue
Block a user