-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from NipunaRanasinghe/test-fixes
Fix test failures
- Loading branch information
Showing
5 changed files
with
163 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Running Tests | ||
|
||
## Prerequisites | ||
|
||
You need to obtain user credentials to run the tests against the Dayforce live server. | ||
|
||
To obtain this, refer to the [Setup guide](https://github.com/ballerina-platform/module-ballerinax-dayforce/blob/main/ballerina/Module.md). | ||
|
||
## Test Environments | ||
|
||
There are two test environments for running the `dayforce` connector tests. The default environment is a mock server for the Dayforce API. The other environment is the Dayforce live server. | ||
|
||
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 Dayforce API (Default Environment) | | ||
| live_tests | Dayforce API | | ||
|
||
## Running Tests in the Mock Server | ||
|
||
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. | ||
|
||
### 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 IS_LIVE_SERVER=false | ||
``` | ||
|
||
For Windows: | ||
|
||
```bash | ||
setx IS_LIVE_SERVER false | ||
``` | ||
|
||
Then, run the following command to execute the tests: | ||
|
||
```bash | ||
./gradlew clean test | ||
``` | ||
|
||
## Running Tests Against the Dayforce Live API | ||
|
||
### Using a `Config.toml` File | ||
|
||
Create a `Config.toml` file in the `tests` directory and add your authentication credentials: | ||
|
||
```toml | ||
isLiveServer = true | ||
username="<your-username>" | ||
password="<your-password>" | ||
``` | ||
|
||
### Using Environment Variables | ||
|
||
Alternatively, you can set your authentication credentials as environment variables. | ||
|
||
For Linux or macOS: | ||
|
||
```bash | ||
export IS_LIVE_SERVER=true | ||
export USERNAME=<your-username> | ||
export PASSWORD=<your-password> | ||
``` | ||
|
||
For Windows: | ||
|
||
```bash | ||
setx IS_LIVE_SERVER true | ||
setx USERNAME <your-username> | ||
setx PASSWORD <your-password> | ||
``` | ||
|
||
Then, run the following command to execute the tests: | ||
|
||
```bash | ||
./gradlew clean test | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). | ||
// | ||
// WSO2 LLC. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/http; | ||
import ballerina/log; | ||
|
||
listener http:Listener httpListener = new (9090); | ||
|
||
http:Service mockService = service object { | ||
|
||
isolated resource function get [string clientNamespace]/V1/Employees/[string xRefCode](string? contextDate = (), string? expand = (), string? contextDateRangeFrom = (), string? contextDateRangeTo = (), string? amfEntity = (), string? amfLevel = (), string? amfLevelValue = ()) returns Payload_Employee|error { | ||
return { | ||
Data: { | ||
EmployeeNumber: xRefCode | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
function init() returns error? { | ||
if isLiveServer { | ||
log:printInfo("Skiping mock server initialization as the tests are running on live server"); | ||
return; | ||
} | ||
log:printInfo("Initiating mock server"); | ||
check httpListener.attach(mockService, "/"); | ||
check httpListener.'start(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters