Skip to content

Commit

Permalink
Update texampleTests.m
Browse files Browse the repository at this point in the history
  • Loading branch information
vpapanasta committed May 15, 2024
1 parent 57741c2 commit 7dfc0a5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/texampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
methods (TestClassSetup)
function setUpAndTearDowns(testCase)
openAIEnvVar = "OPENAI_KEY";
key = getenv(openAIEnvVar);
writelines("OPENAI_API_KEY="+key,".env");
secretKey = getenv(openAIEnvVar);
% Create an empty .env file because it is expected by our .mlx
% example files
writelines("",".env");

% Assign the value of the secret key to OPENAI_API_KEY using
% the test fixture
import matlab.unittest.fixtures.EnvironmentVariableFixture
fixture = EnvironmentVariableFixture("OPENAI_API_KEY", secretKey);
testCase.applyFixture(fixture);

testCase.addTeardown(@() delete(".env"));
testCase.addTeardown(@() unsetenv("OPENAI_API_KEY"));
testCase.addTeardown(@() iCloseAll());
end
end
Expand Down

0 comments on commit 7dfc0a5

Please sign in to comment.