Search code examples
wso2ballerina

configurable values not getting from config.toml when bal test


I have some configurable values in my ballerina project. It is a ballerina service.

public configurable string[] validScopes = ?;
public configurable string[] validAlgorithms = ?;

To set the configurable I'm using a config.toml file like below.

validScopes = ["accounts","payments"]
validAlgorithms = ["HS256","HS384","HS512","RS256","RS384","RS512","ES256","ES384","ES512"]

When I run the project using bal run command then it working fine. But when I use bal test command to run the unit test then I'm getting an error error: value not provided for required configurable variable 'validScopes'.

Is there any config we have to put in the test.bal file to solve this?


Solution

  • see https://ballerina.io/learn/test-ballerina-code/structure-tests/

    Configurations for testing can be provided using configurable variables. The values for configurable variables can be provided in a file named Config.toml located in the tests directory.

    For information on using configurable variables, see https://ballerina.io/learn/configure-ballerina-programs/configure-a-sample-ballerina-service/