Skip to content

Commit a22bdd8

Browse files
committed
Adding test for azureChat when deployment and endpoint cannot be found/are not available
1 parent a7f7634 commit a22bdd8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/tazureChat.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,26 @@ function canUseAPIVersions(testCase, APIVersions)
170170
response = testCase.verifyWarningFree(@() generate(chat,"How similar is the DNA of a cat and a tiger?"));
171171
testCase.verifyClass(response,'string');
172172
testCase.verifyGreaterThan(strlength(response),0);
173+
end
173174

175+
function endpointNotFound(testCase)
176+
% to verify the error, we need to unset the environment variable
177+
% AZURE_OPENAI_ENDPOINT, if given. Use a fixture to restore the
178+
% value on leaving the test point
179+
import matlab.unittest.fixtures.EnvironmentVariableFixture
180+
testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_ENDPOINT","dummy"));
181+
unsetenv("AZURE_OPENAI_ENDPOINT");
182+
testCase.verifyError(@()azureChat, "llms:endpointMustBeSpecified");
183+
end
184+
185+
function deploymentNotFound(testCase)
186+
% to verify the error, we need to unset the environment variable
187+
% AZURE_OPENAI_DEPLOYMENT, if given. Use a fixture to restore the
188+
% value on leaving the test point
189+
import matlab.unittest.fixtures.EnvironmentVariableFixture
190+
testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_DEPLOYMENT","dummy"));
191+
unsetenv("AZURE_OPENAI_DEPLOYMENT");
192+
testCase.verifyError(@()azureChat, "deploymentMustBeSpecified");
174193
end
175194
end
176195
end

0 commit comments

Comments
 (0)