Skip to content

Commit

Permalink
Adding test for azureChat when deployment and endpoint cannot be foun…
Browse files Browse the repository at this point in the history
…d/are not available
  • Loading branch information
vpapanasta committed Jun 27, 2024
1 parent a7f7634 commit a22bdd8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/tazureChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,26 @@ function canUseAPIVersions(testCase, APIVersions)
response = testCase.verifyWarningFree(@() generate(chat,"How similar is the DNA of a cat and a tiger?"));
testCase.verifyClass(response,'string');
testCase.verifyGreaterThan(strlength(response),0);
end

function endpointNotFound(testCase)
% to verify the error, we need to unset the environment variable
% AZURE_OPENAI_ENDPOINT, if given. Use a fixture to restore the
% value on leaving the test point
import matlab.unittest.fixtures.EnvironmentVariableFixture
testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_ENDPOINT","dummy"));
unsetenv("AZURE_OPENAI_ENDPOINT");
testCase.verifyError(@()azureChat, "llms:endpointMustBeSpecified");
end

function deploymentNotFound(testCase)
% to verify the error, we need to unset the environment variable
% AZURE_OPENAI_DEPLOYMENT, if given. Use a fixture to restore the
% value on leaving the test point
import matlab.unittest.fixtures.EnvironmentVariableFixture
testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_DEPLOYMENT","dummy"));
unsetenv("AZURE_OPENAI_DEPLOYMENT");
testCase.verifyError(@()azureChat, "deploymentMustBeSpecified");
end
end
end
Expand Down

0 comments on commit a22bdd8

Please sign in to comment.