diff --git a/internal/handlers/users_test.go b/internal/handlers/users_test.go index 6ee4829..ef399cc 100644 --- a/internal/handlers/users_test.go +++ b/internal/handlers/users_test.go @@ -1,6 +1,7 @@ package handlers_test import ( + "github.com/aclindsa/moneygo/internal/handlers" "net/http" "strconv" "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) { RunWith(t, &data[0], func(t *testing.T, d *TestData) { u, err := getUser(d.clients[0], d.users[0].UserId)