test(tray): add WindowsFactAttribute; skip DPAPI test on non-Windows
SettingsManager_ProtectsElevenLabsApiKeyForStorage calls ProtectSettingSecret, which intentionally throws PlatformNotSupportedException on non-Windows (DPAPI is Windows-only). The test had no platform guard, so it produced a spurious failure on every Linux CI run. Adds WindowsFactAttribute following the same pattern as IntegrationFactAttribute: a custom FactAttribute subclass that sets Skip automatically when the test runs on a non-Windows platform. Applies it to the one DPAPI test. The test continues to run and assert fully on Windows CI (windows-latest). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
871b959ed9
commit
1bcd36ca76
@ -215,7 +215,7 @@ public class SettingsRoundTripTests
|
||||
Assert.Null(SettingsData.FromJson("not json at all"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[WindowsFact]
|
||||
public void SettingsManager_ProtectsElevenLabsApiKeyForStorage()
|
||||
{
|
||||
var protectedValue = SettingsManager.ProtectSettingSecret("elevenlabs-key");
|
||||
|
||||
19
tests/OpenClaw.Tray.Tests/WindowsFactAttribute.cs
Normal file
19
tests/OpenClaw.Tray.Tests/WindowsFactAttribute.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Xunit;
|
||||
|
||||
namespace OpenClaw.Tray.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Marks a test that can only run on Windows (e.g. tests that exercise
|
||||
/// Windows Data Protection API, NTFS reparse points, or other Win32 surfaces).
|
||||
/// The test is automatically skipped on non-Windows platforms.
|
||||
/// </summary>
|
||||
public sealed class WindowsFactAttribute : FactAttribute
|
||||
{
|
||||
public WindowsFactAttribute()
|
||||
{
|
||||
if (!OperatingSystem.IsWindows())
|
||||
{
|
||||
Skip = "Windows-only: requires a Windows platform API.";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user