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
|
// the whole pipeline through a real gateway: login, teams, overworld fights, a MOC floor
|
||||||
public class FlowTests(ITestOutputHelper output)
|
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,
|
// 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
|
// 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]
|
[Fact]
|
||||||
public async Task RosterAndTeamsLoad()
|
public async Task RosterAndTeamsLoad()
|
||||||
@@ -283,9 +283,14 @@ public class FlowTests(ITestOutputHelper output)
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task CalyxPlaysTheConfiguredBattle()
|
public async Task CalyxPlaysTheConfiguredBattle()
|
||||||
{
|
{
|
||||||
|
if (!HasData)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var configured = World.Player.BattleConfig;
|
var configured = World.Player.BattleConfig;
|
||||||
|
|
||||||
if (!HasData || configured.StageId == 0)
|
if (configured.StageId == 0)
|
||||||
{
|
{
|
||||||
output.WriteLine("no srtools battle_config; skipping");
|
output.WriteLine("no srtools battle_config; skipping");
|
||||||
return;
|
return;
|
||||||
@@ -489,6 +494,11 @@ public class FlowTests(ITestOutputHelper output)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!HasData)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var floor = World.Data.Challenges.Values
|
var floor = World.Data.Challenges.Values
|
||||||
.Where(c => c.Kind == Data.Excel.ChallengeKind.MemoryOfChaos && c.NodeCount == 2)
|
.Where(c => c.Kind == Data.Excel.ChallengeKind.MemoryOfChaos && c.NodeCount == 2)
|
||||||
.OrderBy(c => c.ID)
|
.OrderBy(c => c.ID)
|
||||||
|
|||||||
@@ -12,12 +12,16 @@ namespace CapySR.Tests;
|
|||||||
public class GatewayIntegrationTests
|
public class GatewayIntegrationTests
|
||||||
{
|
{
|
||||||
// one world for the whole class; loading the tables is the slow part
|
// one world for the whole class; loading the tables is the slow part
|
||||||
private static readonly GameWorld World =
|
private static GameWorld World => TestWorld.Current;
|
||||||
new(new ServerConfig(), NullLogger.Instance);
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ClientCompletesHandshakeAndLogin()
|
public async Task ClientCompletesHandshakeAndLogin()
|
||||||
{
|
{
|
||||||
|
if (!TestWorld.Available)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var port = FreeUdpPort();
|
var port = FreeUdpPort();
|
||||||
// Persist off: a test must not read or write the machine's saved profile
|
// 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 } };
|
var config = new ServerConfig { GameServer = { Host = "127.0.0.1", Port = port, Nickname = "Capybara", Persist = false } };
|
||||||
@@ -54,6 +58,11 @@ public class GatewayIntegrationTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task UnmodelledRequestStillGetsAnswered()
|
public async Task UnmodelledRequestStillGetsAnswered()
|
||||||
{
|
{
|
||||||
|
if (!TestWorld.Available)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var port = FreeUdpPort();
|
var port = FreeUdpPort();
|
||||||
var config = new ServerConfig { GameServer = { Host = "127.0.0.1", Port = port, Persist = false } };
|
var config = new ServerConfig { GameServer = { Host = "127.0.0.1", Port = port, Persist = false } };
|
||||||
var handlers = HandlerRegistry.Build(NullLogger.Instance);
|
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