Add a test to check that maps are not saved postmapinit (#1987)

This commit is contained in:
DrSmugleaf
2020-09-02 01:16:42 +02:00
committed by GitHub
parent 61f64e15f2
commit b132a4c2d9
2 changed files with 60 additions and 1 deletions

View File

@@ -0,0 +1,60 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
using Robust.Shared.Interfaces.Resources;
using Robust.Shared.Utility;
using YamlDotNet.RepresentationModel;
namespace Content.IntegrationTests.Tests
{
[TestFixture]
public class PostMapInitTest : ContentIntegrationTest
{
public readonly string[] SkippedMaps =
{
"/Maps/Pathfinding/simple.yml"
};
[Test]
public async Task NoSavedPostMapInitTest()
{
var server = StartServerDummyTicker();
await server.WaitIdleAsync();
var resourceManager = server.ResolveDependency<IResourceManager>();
var mapFolder = new ResourcePath("/Maps");
var maps = resourceManager
.ContentFindFiles(mapFolder)
.Where(filePath => filePath.Extension == "yml" && !filePath.Filename.StartsWith("."))
.ToArray();
foreach (var map in maps)
{
var rootedPath = map.ToRootedPath();
if (SkippedMaps.Contains(rootedPath.ToString()))
{
continue;
}
if (!resourceManager.TryContentFileRead(rootedPath, out var fileStream))
{
Assert.Fail($"Map not found: {rootedPath}");
}
using var reader = new StreamReader(fileStream);
var yamlStream = new YamlStream();
yamlStream.Load(reader);
var root = yamlStream.Documents[0].RootNode;
var meta = root["meta"];
var postMapInit = meta["postmapinit"].AsBool();
Assert.False(postMapInit);
}
}
}
}