Make AllComponentsOneToOneDeleteTest skip components with Required fields (#30582)
This commit is contained in:
@@ -9,6 +9,7 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
@@ -333,6 +334,33 @@ namespace Content.IntegrationTests.Tests
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
private static bool HasRequiredDataField(Component component)
|
||||
{
|
||||
foreach (var field in component.GetType().GetFields())
|
||||
{
|
||||
foreach (var attribute in field.GetCustomAttributes(true))
|
||||
{
|
||||
if (attribute is not DataFieldAttribute dataField)
|
||||
continue;
|
||||
|
||||
if (dataField.Required)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach (var property in component.GetType().GetProperties())
|
||||
{
|
||||
foreach (var attribute in property.GetCustomAttributes(true))
|
||||
{
|
||||
if (attribute is not DataFieldAttribute dataField)
|
||||
continue;
|
||||
|
||||
if (dataField.Required)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AllComponentsOneToOneDeleteTest()
|
||||
{
|
||||
@@ -357,9 +385,6 @@ namespace Content.IntegrationTests.Tests
|
||||
"ActivatableUI", // Requires enum key
|
||||
};
|
||||
|
||||
// TODO TESTS
|
||||
// auto ignore any components that have a "required" data field.
|
||||
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
@@ -380,6 +405,9 @@ namespace Content.IntegrationTests.Tests
|
||||
var component = (Component)componentFactory.GetComponent(type);
|
||||
var name = componentFactory.GetComponentName(type);
|
||||
|
||||
if (HasRequiredDataField(component))
|
||||
continue;
|
||||
|
||||
// If this component is ignored
|
||||
if (skipComponents.Contains(name))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user