fix: 更新单元测试适配新模型

- RouteCacheTests: 使用 Fengling.Platform.Domain
- 更新 Id 类型为 string (Guid)
- 更新 PathPattern 为 Match.Path
- TenantRoutingMiddlewareTests: 更新 Id 类型为 string
This commit is contained in:
movingsam 2026-03-04 13:45:04 +08:00
parent 449fe3a385
commit cc11c7258f
2 changed files with 35 additions and 35 deletions

View File

@ -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
};

View File

@ -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,