Skip to content

Commit

Permalink
Merge pull request #16 from KATTA-00/tests
Browse files Browse the repository at this point in the history
Update env variable names in test.bal
  • Loading branch information
NipunaRanasinghe authored Aug 16, 2024
2 parents a6fb9ff + ed57da3 commit 272f17c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
14 changes: 7 additions & 7 deletions ballerina/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand All @@ -71,15 +71,15 @@ Alternatively, you can set your authentication credentials as environment variab
For Linux or macOS:

```bash
export isLiveServer=true
export token="<your-openAI-api-key>"
export IS_LIVE_SERVER=true
export OPENAI_API_KEY="<your-openAI-api-key>"
```

For Windows:

```bash
setx isLiveServer true
setx token <your-openAI-api-key>
setx IS_LIVE_SERVER true
setx OPENAI_API_KEY <your-openAI-api-key>
```

Then, run the following command to execute the tests:
Expand Down
7 changes: 3 additions & 4 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 272f17c

Please sign in to comment.