From cc11c7258f7ba8e44560a9c9f3f7c5c97468893f Mon Sep 17 00:00:00 2001 From: movingsam Date: Wed, 4 Mar 2026 13:45:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=80=82=E9=85=8D=E6=96=B0=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - RouteCacheTests: 使用 Fengling.Platform.Domain - 更新 Id 类型为 string (Guid) - 更新 PathPattern 为 Match.Path - TenantRoutingMiddlewareTests: 更新 Id 类型为 string --- .../TenantRoutingMiddlewareTests.cs | 12 ++-- ...teCacheTests.cs.bak => RouteCacheTests.cs} | 58 +++++++++---------- 2 files changed, 35 insertions(+), 35 deletions(-) rename tests/YarpGateway.Tests/Unit/Services/{RouteCacheTests.cs.bak => RouteCacheTests.cs} (86%) diff --git a/tests/YarpGateway.Tests/Unit/Middleware/TenantRoutingMiddlewareTests.cs b/tests/YarpGateway.Tests/Unit/Middleware/TenantRoutingMiddlewareTests.cs index 73ebbf2..9c50956 100644 --- a/tests/YarpGateway.Tests/Unit/Middleware/TenantRoutingMiddlewareTests.cs +++ b/tests/YarpGateway.Tests/Unit/Middleware/TenantRoutingMiddlewareTests.cs @@ -87,7 +87,7 @@ public class TenantRoutingMiddlewareTests // Arrange var routeInfo = new RouteInfo { - Id = 1, + Id = "1", ClusterId = "cluster-user-service", PathPattern = "/api/user-service/**", Priority = 1, @@ -147,7 +147,7 @@ public class TenantRoutingMiddlewareTests // Arrange var routeInfo = new RouteInfo { - Id = 1, + Id = "1", ClusterId = "cluster-1", IsGlobal = false }; @@ -173,7 +173,7 @@ public class TenantRoutingMiddlewareTests // Arrange var routeInfo = new RouteInfo { - Id = 1, + Id = "1", ClusterId = "cluster-1", IsGlobal = false }; @@ -224,7 +224,7 @@ public class TenantRoutingMiddlewareTests // Arrange var routeInfo = new RouteInfo { - Id = 1, + Id = "1", ClusterId = "cluster-1", IsGlobal = false }; @@ -249,7 +249,7 @@ public class TenantRoutingMiddlewareTests // Arrange var routeInfo = new RouteInfo { - Id = 1, + Id = "1", ClusterId = "global-cluster", IsGlobal = true }; @@ -292,7 +292,7 @@ public class TenantRoutingMiddlewareTests var tenantRoute = new RouteInfo { - Id = 1, + Id = "1", ClusterId = "tenant-specific-cluster", IsGlobal = false }; diff --git a/tests/YarpGateway.Tests/Unit/Services/RouteCacheTests.cs.bak b/tests/YarpGateway.Tests/Unit/Services/RouteCacheTests.cs similarity index 86% rename from tests/YarpGateway.Tests/Unit/Services/RouteCacheTests.cs.bak rename to tests/YarpGateway.Tests/Unit/Services/RouteCacheTests.cs index 021e0df..f701603 100644 --- a/tests/YarpGateway.Tests/Unit/Services/RouteCacheTests.cs.bak +++ b/tests/YarpGateway.Tests/Unit/Services/RouteCacheTests.cs @@ -4,7 +4,7 @@ using Moq; using Xunit; using FluentAssertions; using YarpGateway.Data; -using YarpGateway.Models; +using Fengling.Platform.Domain.AggregatesModel.GatewayAggregate; using YarpGateway.Services; namespace YarpGateway.Tests.Unit.Services; @@ -53,11 +53,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "user-service", ClusterId = "cluster-user", - PathPattern = "/api/user/**", + Match = new GwRouteMatch { Path = "/api/user/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -65,11 +65,11 @@ public class RouteCacheTests }, new GwTenantRoute { - Id = 2, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "order-service", ClusterId = "cluster-order", - PathPattern = "/api/order/**", + Match = new GwRouteMatch { Path = "/api/order/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -97,11 +97,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "tenant-1", ServiceName = "user-service", ClusterId = "cluster-tenant-user", - PathPattern = "/api/user/**", + Match = new GwRouteMatch { Path = "/api/user/**" }, Priority = 1, Status = 1, IsGlobal = false, @@ -129,11 +129,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "tenant-1", ServiceName = "user-service", ClusterId = "tenant-cluster", - PathPattern = "/api/user/**", + Match = new GwRouteMatch { Path = "/api/user/**" }, Priority = 1, Status = 1, IsGlobal = false, @@ -141,11 +141,11 @@ public class RouteCacheTests }, new GwTenantRoute { - Id = 2, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "user-service", ClusterId = "global-cluster", - PathPattern = "/api/user/**", + Match = new GwRouteMatch { Path = "/api/user/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -173,11 +173,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "user-service", ClusterId = "global-cluster", - PathPattern = "/api/user/**", + Match = new GwRouteMatch { Path = "/api/user/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -222,11 +222,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "user-service", ClusterId = "cluster-user", - PathPattern = "/api/user/**", + Match = new GwRouteMatch { Path = "/api/user/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -271,11 +271,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "old-service", ClusterId = "old-cluster", - PathPattern = "/api/old/**", + Match = new GwRouteMatch { Path = "/api/old/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -294,11 +294,11 @@ public class RouteCacheTests context.TenantRoutes.RemoveRange(context.TenantRoutes); context.TenantRoutes.Add(new GwTenantRoute { - Id = 2, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "new-service", ClusterId = "new-cluster", - PathPattern = "/api/new/**", + Match = new GwRouteMatch { Path = "/api/new/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -322,11 +322,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "active-service", ClusterId = "cluster-1", - PathPattern = "/api/active/**", + Match = new GwRouteMatch { Path = "/api/active/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -334,11 +334,11 @@ public class RouteCacheTests }, new GwTenantRoute { - Id = 2, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "deleted-service", ClusterId = "cluster-2", - PathPattern = "/api/deleted/**", + Match = new GwRouteMatch { Path = "/api/deleted/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -363,11 +363,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "active-service", ClusterId = "cluster-1", - PathPattern = "/api/active/**", + Match = new GwRouteMatch { Path = "/api/active/**" }, Priority = 1, Status = 1, IsGlobal = true, @@ -375,11 +375,11 @@ public class RouteCacheTests }, new GwTenantRoute { - Id = 2, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "inactive-service", ClusterId = "cluster-2", - PathPattern = "/api/inactive/**", + Match = new GwRouteMatch { Path = "/api/inactive/**" }, Priority = 1, Status = 0, // Inactive IsGlobal = true, @@ -404,11 +404,11 @@ public class RouteCacheTests { new GwTenantRoute { - Id = 1, + Id = Guid.CreateVersion7().ToString("N"), TenantCode = "", ServiceName = "user-service", ClusterId = "cluster-user", - PathPattern = "/api/user/**", + Match = new GwRouteMatch { Path = "/api/user/**" }, Priority = 1, Status = 1, IsGlobal = true,