Fix: unittests
This commit is contained in:
		| @@ -75,13 +75,13 @@ func createRoom(ctx context.Context, req *models.RoomReq) (*models.Room, error) | ||||
| // 	repo.CreateRoom() | ||||
| // } | ||||
|  | ||||
| func saveFullInfo(fi *models.FullInfo) error { | ||||
| func saveFullInfo(ctx context.Context, fi *models.FullInfo) error { | ||||
| 	// INFO: no transactions; so case is possible where first object is updated but the second is not | ||||
| 	if err := repo.PlayerUpdate(fi.State); err != nil { | ||||
| 	if err := repo.PlayerUpdate(ctx, fi.State); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	log.Debug("saved user state", "state", fi.State) | ||||
| 	if err := repo.RoomUpdate(context.Background(), fi.Room); err != nil { | ||||
| 	if err := repo.RoomUpdate(ctx, fi.Room); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	return nil | ||||
| @@ -155,7 +155,7 @@ func getPlayerByCtx(ctx context.Context) (*models.Player, error) { | ||||
| 		log.Debug("no username in ctx") | ||||
| 		return &models.Player{}, errors.New("no username in ctx") | ||||
| 	} | ||||
| 	return repo.PlayerGetByName(username) | ||||
| 	return repo.PlayerGetByName(ctx, username) | ||||
| } | ||||
|  | ||||
| // // DEPRECATED | ||||
| @@ -219,7 +219,7 @@ func joinTeam(ctx context.Context, role, team string) (*models.FullInfo, error) | ||||
| 		err := errors.New("uknown role:" + role) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if err := saveFullInfo(fi); err != nil { | ||||
| 	if err := saveFullInfo(ctx, fi); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return fi, nil | ||||
| @@ -247,7 +247,7 @@ func joinTeam(ctx context.Context, role, team string) (*models.FullInfo, error) | ||||
|  | ||||
| // get bots | ||||
| func listBots() []models.Player { | ||||
| 	bots, err := repo.PlayerList(true) | ||||
| 	bots, err := repo.PlayerList(context.Background(), true) | ||||
| 	if err != nil { | ||||
| 		log.Error("failed to fetch bots from db", "error", err) | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder