2024-10-02 11:42:27 -07:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
2024-08-08 16:33:14 -07:00
|
|
|
// OpenAIFact.cs
|
|
|
|
|
|
|
|
namespace AutoGen.Tests;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A fact for tests requiring OPENAI_API_KEY env.
|
|
|
|
/// </summary>
|
|
|
|
public sealed class ApiKeyFactAttribute : EnvironmentSpecificFactAttribute
|
|
|
|
{
|
|
|
|
private readonly string[] _envVariableNames;
|
|
|
|
public ApiKeyFactAttribute(params string[] envVariableNames) : base($"{envVariableNames} is not found in env")
|
|
|
|
{
|
|
|
|
_envVariableNames = envVariableNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override bool IsEnvironmentSupported()
|
|
|
|
{
|
|
|
|
return _envVariableNames.All(Environment.GetEnvironmentVariables().Contains);
|
|
|
|
}
|
|
|
|
}
|