diff --git a/ballerina/tests/README.md b/ballerina/tests/README.md index cca0034..a818d1a 100644 --- a/ballerina/tests/README.md +++ b/ballerina/tests/README.md @@ -19,7 +19,7 @@ You can run the tests in either of these environments, and each has its own comp ## Running Tests in the Mock Server -To execute the tests on the mock server, ensure that the `isLiveServer` environment variable is either set to `false` or left unset before initiating the tests. +To execute the tests on the mock server, ensure that the `IS_LIVE_SERVER` environment variable is either set to `false` or left unset before initiating the tests. This environment variable can be configured within the `Config.toml` file located in the `tests` directory or specified as an environment variable. @@ -38,13 +38,13 @@ Alternatively, you can set the environment variable directly. For Linux or macOS: ```bash -export isLiveServer=false +export IS_LIVE_SERVER=false ``` For Windows: ```bash -setx isLiveServer false +setx IS_LIVE_SERVER false ``` Then, run the following command to execute the tests: @@ -71,15 +71,15 @@ Alternatively, you can set your authentication credentials as environment variab For Linux or macOS: ```bash -export isLiveServer=true -export token="" +export IS_LIVE_SERVER=true +export OPENAI_API_KEY="" ``` For Windows: ```bash -setx isLiveServer true -setx token +setx IS_LIVE_SERVER true +setx OPENAI_API_KEY ``` Then, run the following command to execute the tests: diff --git a/ballerina/tests/test.bal b/ballerina/tests/test.bal index 14003a1..c286cdd 100644 --- a/ballerina/tests/test.bal +++ b/ballerina/tests/test.bal @@ -17,14 +17,13 @@ import ballerina/os; import ballerina/test; -configurable boolean isLiveServer = os:getEnv("isLiveServer") == "true"; -configurable string token = isLiveServer ? os:getEnv("OPENAI_API_KEY") : "test"; +configurable boolean isLiveServer = os:getEnv("IS_LIVE_SERVER") == "true"; +configurable string token = isLiveServer ? os:getEnv("OPENAI_API_KEY") : ""; configurable string serviceUrl = isLiveServer ? "https://api.openai.com/v1" : "http://localhost:9090"; -configurable string apiKey = isLiveServer ? token : ""; final ConnectionConfig config = { auth: { - token: apiKey + token } }; final Client openAIFinetunes = check new Client(config, serviceUrl);