Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases and implement the mock server #8

Merged
merged 39 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
36b7236
adding test and mock server implementations
KATTA-00 Aug 8, 2024
ada85e3
adding check keyword and removing error handling
KATTA-00 Aug 8, 2024
67d4796
commenting not implemeted services
KATTA-00 Aug 9, 2024
2417191
Add test for fine-tuning job cancellation and file deletion endpoints
KATTA-00 Aug 9, 2024
95229c7
Add a README.md for test
KATTA-00 Aug 9, 2024
868ea36
Replace io.fileReadBytes with a byte array
KATTA-00 Aug 9, 2024
94f3c8e
Update test cases using moduler var
KATTA-00 Aug 9, 2024
48e789b
update test.bal
KATTA-00 Aug 9, 2024
168de9f
refractor the test.bal
KATTA-00 Aug 12, 2024
7d14adb
Merge branch 'main' of https://github.com/KATTA-00/module-ballerinax-…
KATTA-00 Aug 12, 2024
69857b2
Merge pull request #8 from KATTA-00/main
KATTA-00 Aug 12, 2024
cab32c1
Merge pull request #9 from KATTA-00/main
KATTA-00 Aug 12, 2024
c754cff
Update docs/setup/resources/sample.jsonl
KATTA-00 Aug 12, 2024
803c7aa
Update ballerina/tests/test.bal
KATTA-00 Aug 12, 2024
e6c7012
Update ballerina/tests/openapi_service.bal
KATTA-00 Aug 12, 2024
ee6e5fa
Rename the openapi_service.bal to mock_service.bal and Add the new ge…
KATTA-00 Aug 12, 2024
8380d40
Update ballerina/tests/test.bal
KATTA-00 Aug 12, 2024
cb37f02
Update test.bal
KATTA-00 Aug 12, 2024
a31cb1f
Update ballerina/tests/mock_service.bal
KATTA-00 Aug 12, 2024
208328d
Update ballerina/tests/test.bal
KATTA-00 Aug 12, 2024
cfa31e1
Update ballerina/tests/test.bal
KATTA-00 Aug 12, 2024
beea746
Remove unwanted lines and comments
KATTA-00 Aug 12, 2024
01254b5
Add groups in test.bal
KATTA-00 Aug 12, 2024
e2b7834
Update ballerina/tests/test.bal
KATTA-00 Aug 12, 2024
9a72350
Update ballerina/tests/mock_service.bal
KATTA-00 Aug 12, 2024
e71229e
Update ballerina/tests/test.bal
KATTA-00 Aug 12, 2024
8c2b395
Update ballerina/tests/test.bal
KATTA-00 Aug 12, 2024
bb1d184
Change openaiFinetunes to openAIFinetunes in test.bal
KATTA-00 Aug 12, 2024
331d585
Refractor the test.bal and mock_service.bal
KATTA-00 Aug 12, 2024
a1171c3
Update sample.jsonl
KATTA-00 Aug 13, 2024
5a21ba4
Update the fileContent byte array
KATTA-00 Aug 13, 2024
d950f70
Update the isLiveServer var with env variables
KATTA-00 Aug 13, 2024
50f3c82
Update ballerina/tests/test.bal
KATTA-00 Aug 13, 2024
3c48274
Add "live_tests", "mock_tests" groups in test.bal
KATTA-00 Aug 13, 2024
d7012a3
Remove dataProvider and use module level var
KATTA-00 Aug 14, 2024
808da4e
Update ballerina/tests/mock_service.bal
KATTA-00 Aug 14, 2024
8110079
Update ballerina/tests/test.bal
KATTA-00 Aug 14, 2024
b66a521
Update ballerina/tests/test.bal
KATTA-00 Aug 14, 2024
d9f0616
Update group naming and formatting
KATTA-00 Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.error"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.int"
Expand Down Expand Up @@ -202,6 +211,9 @@ dependencies = [
{org = "ballerina", name = "lang.value"},
{org = "ballerina", name = "observe"}
]
modules = [
{org = "ballerina", packageName = "log", moduleName = "log"}
]

[[package]]
org = "ballerina"
Expand Down Expand Up @@ -255,6 +267,20 @@ dependencies = [
{org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "test"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.array"},
{org = "ballerina", name = "lang.error"}
]
modules = [
{org = "ballerina", packageName = "test", moduleName = "test"}
]

[[package]]
org = "ballerina"
name = "time"
Expand Down Expand Up @@ -292,7 +318,9 @@ name = "openai.finetunes"
version = "1.0.5"
dependencies = [
{org = "ballerina", name = "http"},
{org = "ballerina", name = "log"},
{org = "ballerina", name = "mime"},
{org = "ballerina", name = "test"},
{org = "ballerina", name = "url"},
{org = "ballerinai", name = "observe"}
]
Expand Down
89 changes: 89 additions & 0 deletions ballerina/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Running Tests

## Prerequisites

You need an API token from OpenAI.

To obtain this, refer to the [Ballerina OpenAI Finetunes Connector](https://github.com/ballerina-platform/module-ballerinax-openai.finetunes/blob/main/ballerina/Module.md).

## Test Environments

There are two test environments for running the `openai.finetunes` 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
token = "<your-openAI-api-key>"
```

### Using Environment Variables

Alternatively, you can set your authentication credentials as environment variables.

For Linux or macOS:

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

For Windows:

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

Then, run the following command to execute the tests:

```bash
./gradlew clean test
```
Loading
Loading