Skip to content

Commit 30a40f5

Browse files
committed
Expect uv cache error when uv missing
1 parent 57ad589 commit 30a40f5

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

TestProjects/UnityMCPTests/Assets/Tests/EditMode/Services/Characterization/ServerManagementServiceCharacterizationTests.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System;
22
using System.Reflection;
3+
using System.Text.RegularExpressions;
34
using NUnit.Framework;
45
using MCPForUnity.Editor.Services;
56
using MCPForUnity.Editor.Constants;
67
using UnityEditor;
8+
using UnityEngine;
9+
using UnityEngine.TestTools;
710

811
namespace MCPForUnityTests.Editor.Services.Characterization
912
{
@@ -337,11 +340,33 @@ public void ClearUvxCache_DoesNotThrow()
337340
// Arrange
338341
_service = new ServerManagementService();
339342

343+
string lastLog = null;
344+
Application.LogCallback handler = (condition, stackTrace, type) =>
345+
{
346+
if (condition != null && condition.Contains("uv cache"))
347+
{
348+
lastLog = condition;
349+
}
350+
};
351+
340352
// Act & Assert - Should not throw even if uvx is not installed
341353
Assert.DoesNotThrow(() =>
342354
{
343-
_service.ClearUvxCache();
355+
LogAssert.ignoreFailingMessages = true;
356+
Application.logMessageReceived += handler;
357+
try
358+
{
359+
_service.ClearUvxCache();
360+
}
361+
finally
362+
{
363+
Application.logMessageReceived -= handler;
364+
LogAssert.ignoreFailingMessages = false;
365+
}
344366
}, "ClearUvxCache should handle missing uvx gracefully");
367+
368+
Assert.IsNotNull(lastLog, "Expected a uv cache log message.");
369+
StringAssert.Contains("uv cache", lastLog);
345370
}
346371

347372
#endregion

0 commit comments

Comments
 (0)