From 63fde7bbfc70e307dd218fd372713a1bc5a3488f Mon Sep 17 00:00:00 2001 From: Rodion Mostovoi Date: Fri, 17 Nov 2023 18:47:18 +0800 Subject: [PATCH] Improve test config validation and adjust environment variables 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. --- .github/workflows/dotnet.yml | 4 ++-- .github/workflows/publish_to_nuget.yml | 4 ++-- tests/OpenAI.Tests.Shared/Helpers.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 9c61605..c6fc8f9 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -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 diff --git a/.github/workflows/publish_to_nuget.yml b/.github/workflows/publish_to_nuget.yml index 56e295f..b8c998e 100644 --- a/.github/workflows/publish_to_nuget.yml +++ b/.github/workflows/publish_to_nuget.yml @@ -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 diff --git a/tests/OpenAI.Tests.Shared/Helpers.cs b/tests/OpenAI.Tests.Shared/Helpers.cs index cd3aec4..d088bc1 100644 --- a/tests/OpenAI.Tests.Shared/Helpers.cs +++ b/tests/OpenAI.Tests.Shared/Helpers.cs @@ -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"); }