From 49370410ad839442957cecb41cb003cbc27b37e1 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 1 Jul 2025 20:31:39 -0400 Subject: [PATCH] Validate `CloningSettingsPrototype`s (#38688) * Validate CloningSettingsPrototypes * Update Content.IntegrationTests/Tests/Cloning/CloningSettingsPrototypeTest.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Check EventComponents too --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- .../Cloning/CloningSettingsPrototypeTest.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Content.IntegrationTests/Tests/Cloning/CloningSettingsPrototypeTest.cs diff --git a/Content.IntegrationTests/Tests/Cloning/CloningSettingsPrototypeTest.cs b/Content.IntegrationTests/Tests/Cloning/CloningSettingsPrototypeTest.cs new file mode 100644 index 0000000000..9edc115eee --- /dev/null +++ b/Content.IntegrationTests/Tests/Cloning/CloningSettingsPrototypeTest.cs @@ -0,0 +1,46 @@ +using Content.Shared.Cloning; + +namespace Content.IntegrationTests.Tests.Cloning; + +public sealed class CloningSettingsPrototypeTest +{ + /// + /// Checks that the components named in every are valid components known to the server. + /// This is used instead of because we only care if the components are registered with the server, + /// and instead of a because we only need component names. + /// + [Test] + public async Task ValidatePrototypes() + { + await using var pair = await PoolManager.GetServerClient(); + var server = pair.Server; + var protoMan = server.ProtoMan; + var compFactory = server.EntMan.ComponentFactory; + + await server.WaitAssertion(() => + { + Assert.Multiple(() => + { + var protos = protoMan.EnumeratePrototypes(); + foreach (var proto in protos) + { + foreach (var compName in proto.Components) + { + Assert.That(compFactory.TryGetRegistration(compName, out _), + $"Failed to find a component named {compName} for {nameof(CloningSettingsPrototype)} \"{proto.ID}\"" + ); + } + + foreach (var eventCompName in proto.EventComponents) + { + Assert.That(compFactory.TryGetRegistration(eventCompName, out _), + $"Failed to find a component named {eventCompName} for {nameof(CloningSettingsPrototype)} \"{proto.ID}\"" + ); + } + } + }); + }); + + await pair.CleanReturnAsync(); + } +} -- 2.51.2