Skip to content

Commit

Permalink
Improve test config validation and adjust environment variables
Browse files Browse the repository at this point in the history
The validation in the Helpers.cs file was modified to throw an exception not only when a configuration value is null, but also when it's empty. This is to further improve error reporting in test scenarios. Also, in publish_to_nuget.yml and dotnet.yml files, environment variables related to Azure OpenAI were adjusted from 'env' to 'vars' for better consistency and to fix possible naming issues when running in GitHub Actions.
  • Loading branch information
rodion-m committed Nov 17, 2023
1 parent fdb60b9 commit 63fde7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT_URL: ${{ env.AZURE_OPENAI_ENDPOINT_URL }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ env.AZURE_OPENAI_DEPLOYMENT_NAME }}
AZURE_OPENAI_ENDPOINT_URL: ${{ vars.AZURE_OPENAI_ENDPOINT_URL }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_DEPLOYMENT_NAME }}
run: dotnet test --no-build --verbosity normal
4 changes: 2 additions & 2 deletions .github/workflows/publish_to_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT_URL: ${{ env.AZURE_OPENAI_ENDPOINT_URL }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ env.AZURE_OPENAI_DEPLOYMENT_NAME }}
AZURE_OPENAI_ENDPOINT_URL: ${{ vars.AZURE_OPENAI_ENDPOINT_URL }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ vars.AZURE_OPENAI_DEPLOYMENT_NAME }}
run: dotnet test --no-build --verbosity normal

- name: Find NuGet packages
Expand Down
2 changes: 1 addition & 1 deletion tests/OpenAI.Tests.Shared/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static string GetValueFromConfiguration(string key)
{
ArgumentNullException.ThrowIfNull(key);
var value = Configuration[key];
if (value is null)
if (value is null or { Length: 0 })
{
throw new InvalidOperationException($"{key} is not set in configuration");
}
Expand Down

0 comments on commit 63fde7b

Please sign in to comment.