mirror of
				https://github.com/aclindsa/moneygo.git
				synced 2025-10-30 01:23:26 -04:00 
			
		
		
		
	Test not allowing users to be re-created with the same username
This commit is contained in:
		| @@ -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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user