fix(tests): skip when game data is absent
This commit is contained in:
1 parent
00601b9140
commit
19d702e1a6
3 files changed
+42
-5
No files matched your search
@@ -13,7 +13,7 @@ namespace CapySR.Tests;
|
||||
// the whole pipeline through a real gateway: login, teams, overworld fights, a MOC floor
|
||||
public class FlowTests(ITestOutputHelper output)
|
||||
{
|
||||
private static readonly GameWorld World = new(TestConfig(), NullLogger.Instance);
|
||||
private static GameWorld World => TestWorld.Current;
|
||||
|
||||
// the default harness plays real stages so an assertion about a fight is about the data,
|
||||
// not about whatever freesr-data.json happens to hold
|
||||
@@ -66,7 +66,7 @@ public class FlowTests(ITestOutputHelper output)
|
||||
}
|
||||
}
|
||||
|
||||
private static bool HasData => new DataConfig().ResolvedSources.Any(Directory.Exists);
|
||||
private static bool HasData => TestWorld.Available;
|
||||
|
||||
[Fact]
|
||||
public async Task RosterAndTeamsLoad()
|
||||
@@ -283,9 +283,14 @@ public class FlowTests(ITestOutputHelper output)
|
||||
[Fact]
|
||||
public async Task CalyxPlaysTheConfiguredBattle()
|
||||
{
|
||||
if (!HasData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var configured = World.Player.BattleConfig;
|
||||
|
||||
if (!HasData || configured.StageId == 0)
|
||||
if (configured.StageId == 0)
|
||||
{
|
||||
output.WriteLine("no srtools battle_config; skipping");
|
||||
return;
|
||||
@@ -489,6 +494,11 @@ public class FlowTests(ITestOutputHelper output)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var floor = World.Data.Challenges.Values
|
||||
.Where(c => c.Kind == Data.Excel.ChallengeKind.MemoryOfChaos && c.NodeCount == 2)
|
||||
.OrderBy(c => c.ID)
|
||||
|
||||
@@ -12,12 +12,16 @@ namespace CapySR.Tests;
|
||||
public class GatewayIntegrationTests
|
||||
{
|
||||
// one world for the whole class; loading the tables is the slow part
|
||||
private static readonly GameWorld World =
|
||||
new(new ServerConfig(), NullLogger.Instance);
|
||||
private static GameWorld World => TestWorld.Current;
|
||||
|
||||
[Fact]
|
||||
public async Task ClientCompletesHandshakeAndLogin()
|
||||
{
|
||||
if (!TestWorld.Available)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var port = FreeUdpPort();
|
||||
// Persist off: a test must not read or write the machine's saved profile
|
||||
var config = new ServerConfig { GameServer = { Host = "127.0.0.1", Port = port, Nickname = "Capybara", Persist = false } };
|
||||
@@ -54,6 +58,11 @@ public class GatewayIntegrationTests
|
||||
[Fact]
|
||||
public async Task UnmodelledRequestStillGetsAnswered()
|
||||
{
|
||||
if (!TestWorld.Available)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var port = FreeUdpPort();
|
||||
var config = new ServerConfig { GameServer = { Host = "127.0.0.1", Port = port, Persist = false } };
|
||||
var handlers = HandlerRegistry.Build(NullLogger.Instance);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using CapySR.Common;
|
||||
using CapySR.GameServer.Game;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
||||
namespace CapySR.Tests;
|
||||
|
||||
// The game data is a separate checkout, so a fresh clone has none. Tests that need it check
|
||||
// Available and return instead of failing. Building the world is deferred for the same
|
||||
// reason, and shared because loading the tables is the slow part of the suite.
|
||||
internal static class TestWorld
|
||||
{
|
||||
private static readonly Lazy<GameWorld> Instance =
|
||||
new(() => new GameWorld(new ServerConfig(), NullLogger.Instance));
|
||||
|
||||
public static bool Available { get; } = new DataConfig().ResolvedSources.Any(Directory.Exists);
|
||||
|
||||
public static GameWorld Current => Instance.Value;
|
||||
}
|
||||
Reference in new issue
Block a user