From a9279e603d38bc73edd4c86afbd3409694a69558 Mon Sep 17 00:00:00 2001 From: G5andeepD Date: Fri, 9 Aug 2024 12:21:39 +0530 Subject: [PATCH] Add documentation for running tests - Instructions for running tests in mock and live environments. - Setup details for environment configuration. --- ballerina/tests/README.md | 89 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 ballerina/tests/README.md diff --git a/ballerina/tests/README.md b/ballerina/tests/README.md new file mode 100644 index 0000000..182c05e --- /dev/null +++ b/ballerina/tests/README.md @@ -0,0 +1,89 @@ +# Running Tests + +## Prerequisites + +You need an API key from OpenAI. + +To obtain this, refer to the [Ballerina OpenAI Images Connector](https://github.com/ballerina-platform/module-ballerinax-openai.images/blob/main/ballerina/Module.md). + +## Test Environments + +There are two test environments for running the `openai.images` connector tests. The default environment is a mock server for the OpenAI API. The other environment is the actual OpenAI API. + +You can run the tests in either of these environments, and each has its own compatible set of tests. + +| Test Groups | Environment | +|-------------|---------------------------------------------------| +| mock_tests | Mock server for OpenAI API (Default Environment) | +| live_tests | OpenAI API | + +## 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. + +This environment variable can be configured within the `Config.toml` file located in the `tests` directory or specified as an environment variable. + +### Using a `Config.toml` File + +Create a `Config.toml` file in the `tests` directory with the following content: + +```toml +isLiveServer = false +``` + +### Using Environment Variables + +Alternatively, you can set the environment variable directly. + +For Linux or macOS: + +```bash +export isLiveServer=false +``` + +For Windows: + +```bash +setx isLiveServer false +``` + +Then, run the following command to execute the tests: + +```bash +./gradlew clean test +``` + +## Running Tests Against the OpenAI Live API + +### Using a `Config.toml` File + +Create a `Config.toml` file in the `tests` directory and add your authentication credentials: + +```toml +isLiveServer = true +apiKey = "" +``` + +### Using Environment Variables + +Alternatively, you can set your authentication credentials as environment variables. + +For Linux or macOS: + +```bash +export isLiveServer=true +export apiKey="" +``` + +For Windows: + +```bash +setx isLiveServer true +setx apiKey +``` + +Then, run the following command to execute the tests: + +```bash +./gradlew clean test +``` \ No newline at end of file