diff --git a/core-service/internal/api/handlers/items_test.go b/core-service/internal/api/handlers/items_test.go index 795d5b4..5fd5198 100644 --- a/core-service/internal/api/handlers/items_test.go +++ b/core-service/internal/api/handlers/items_test.go @@ -159,8 +159,7 @@ func TestItemHandler_CreateItem_Success(t *testing.T) { router := gin.New() router.POST("/items", func(c *gin.Context) { - // Устанавливаем claims в контекст - c.Set("organization_id", orgID) + setClaims(c, orgID) handler.CreateItem(c) }) @@ -203,8 +202,7 @@ func TestItemHandler_CreateItem_ValidationError(t *testing.T) { router := gin.New() router.POST("/items", func(c *gin.Context) { - // Устанавливаем claims в контекст - c.Set("organization_id", orgID) + setClaims(c, orgID) handler.CreateItem(c) }) @@ -240,12 +238,11 @@ func TestItemHandler_GetItem_Success(t *testing.T) { Category: "electronics", } - mockItemService.On("GetItem", mock.Anything, orgID, itemID).Return(expectedItem, nil) + mockItemService.On("GetItem", mock.Anything, itemID, orgID).Return(expectedItem, nil) router := gin.New() router.GET("/items/:id", func(c *gin.Context) { - // Устанавливаем claims в контекст - c.Set("organization_id", orgID) + setClaims(c, orgID) handler.GetItem(c) }) @@ -289,8 +286,7 @@ func TestItemHandler_SearchItems_Success(t *testing.T) { router := gin.New() router.GET("/items/search", func(c *gin.Context) { - // Устанавливаем claims в контекст - c.Set("organization_id", orgID) + setClaims(c, orgID) handler.SearchItems(c) }) diff --git a/core-service/internal/api/handlers/locations_test.go b/core-service/internal/api/handlers/locations_test.go index d557a56..439387d 100644 --- a/core-service/internal/api/handlers/locations_test.go +++ b/core-service/internal/api/handlers/locations_test.go @@ -95,7 +95,10 @@ func TestLocationHandler_GetLocations_Success(t *testing.T) { router := gin.New() router.GET("/locations", func(c *gin.Context) { // Устанавливаем claims в контекст + c.Set("user_id", uuid.New()) c.Set("organization_id", orgID) + c.Set("email", "test@example.com") + c.Set("role", "admin") handler.GetLocations(c) }) @@ -148,7 +151,10 @@ func TestLocationHandler_CreateLocation_Success(t *testing.T) { router := gin.New() router.POST("/locations", func(c *gin.Context) { // Устанавливаем claims в контекст + c.Set("user_id", uuid.New()) c.Set("organization_id", orgID) + c.Set("email", "test@example.com") + c.Set("role", "admin") handler.CreateLocation(c) }) @@ -192,7 +198,10 @@ func TestLocationHandler_CreateLocation_ValidationError(t *testing.T) { router := gin.New() router.POST("/locations", func(c *gin.Context) { // Устанавливаем claims в контекст + c.Set("user_id", uuid.New()) c.Set("organization_id", orgID) + c.Set("email", "test@example.com") + c.Set("role", "admin") handler.CreateLocation(c) }) @@ -228,12 +237,15 @@ func TestLocationHandler_GetLocation_Success(t *testing.T) { Type: "warehouse", } - mockLocationService.On("GetLocation", mock.Anything, orgID, locationID).Return(expectedLocation, nil) + mockLocationService.On("GetLocation", mock.Anything, locationID, orgID).Return(expectedLocation, nil) router := gin.New() router.GET("/locations/:id", func(c *gin.Context) { // Устанавливаем claims в контекст + c.Set("user_id", uuid.New()) c.Set("organization_id", orgID) + c.Set("email", "test@example.com") + c.Set("role", "admin") handler.GetLocation(c) }) @@ -283,12 +295,15 @@ func TestLocationHandler_GetChildren_Success(t *testing.T) { }, } - mockLocationService.On("GetChildren", mock.Anything, orgID, parentID).Return(expectedChildren, nil) + mockLocationService.On("GetChildren", mock.Anything, parentID, orgID).Return(expectedChildren, nil) router := gin.New() router.GET("/locations/:id/children", func(c *gin.Context) { // Устанавливаем claims в контекст + c.Set("user_id", uuid.New()) c.Set("organization_id", orgID) + c.Set("email", "test@example.com") + c.Set("role", "admin") handler.GetChildren(c) })