Skip to content

Commit 5ed246d

Browse files
committed
Add explanatory comment for missing key test.
Also, move it down to the error tests.
1 parent 88f054b commit 5ed246d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/tazureChat.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
end
1111

1212
methods(Test)
13-
% Test methods
14-
function keyNotFound(testCase)
15-
import matlab.unittest.fixtures.EnvironmentVariableFixture
16-
testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_API_KEY","dummy"));
17-
unsetenv("AZURE_OPENAI_API_KEY");
18-
testCase.verifyError(@()azureChat(getenv("AZURE_OPENAI_ENDPOINT"), getenv("AZURE_OPENAI_DEPLOYMENT")), "llms:keyMustBeSpecified");
19-
end
20-
2113
function constructChatWithAllNVP(testCase)
2214
endpoint = getenv("AZURE_OPENAI_ENDPOINT");
2315
deploymentID = "hello";
@@ -100,6 +92,16 @@ function assignValueToProperty(property, value)
10092

10193
testCase.verifyError(@()assignValueToProperty(InvalidValuesSetters.Property,InvalidValuesSetters.Value), InvalidValuesSetters.Error);
10294
end
95+
96+
function keyNotFound(testCase)
97+
% to verify the error, we need to unset the environment variable
98+
% AZURE_OPENAI_API_KEY, if given. Use a fixture to restore the
99+
% value on leaving the test point:
100+
import matlab.unittest.fixtures.EnvironmentVariableFixture
101+
testCase.applyFixture(EnvironmentVariableFixture("AZURE_OPENAI_API_KEY","dummy"));
102+
unsetenv("AZURE_OPENAI_API_KEY");
103+
testCase.verifyError(@()azureChat(getenv("AZURE_OPENAI_ENDPOINT"), getenv("AZURE_OPENAI_DEPLOYMENT")), "llms:keyMustBeSpecified");
104+
end
103105
end
104106
end
105107

0 commit comments

Comments
 (0)