Skip to content

Commit

Permalink
add more unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
maggie98choy committed Aug 12, 2024
1 parent 7ee3428 commit f86a9b6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/main/src/broker/endpoint_broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,5 +1077,25 @@ mod tests {
apply_response(response, filter, &rpc_request, &mut output);

Check warning on line 1078 in core/main/src/broker/endpoint_broker.rs

View workflow job for this annotation

GitHub Actions / Format checker

Diff in /home/runner/work/Ripple/Ripple/core/main/src/broker/endpoint_broker.rs
assert_eq!(output.data.result.unwrap(), "null");

// securestorage.get
let result = json!({"value": "some_value","success": true,"ttl": 100});
let data = JsonRpcApiResponse::mock();
let mut output: BrokerOutput = BrokerOutput { data: data.clone() };
let filter = "if .result.success then .result.value else \"null\" end".to_string();
let mut response = JsonRpcApiResponse::mock();
response.result = Some(result);
apply_response(response, filter, &rpc_request, &mut output);
assert_eq!(output.data.result.unwrap(), "some_value");

// localization.countryCode
let result = json!({"territory": "USA","success": true});
let data = JsonRpcApiResponse::mock();
let mut output: BrokerOutput = BrokerOutput { data: data.clone() };
let filter = "if .result.success then if .result.territory == \"ITA\" then \"IT\" elif .result.territory == \"GBR\" then \"GB\" elif .result.territory == \"IRL\" then \"IE\" elif .result.territory == \"DEU\" then \"DE\" elif .result.territory == \"AUS\" then \"AU\" else \"GB\" end end".to_string();
let mut response = JsonRpcApiResponse::mock();
response.result = Some(result);
apply_response(response, filter, &rpc_request, &mut output);
assert_eq!(output.data.result.unwrap(), "GB");
}
}

0 comments on commit f86a9b6

Please sign in to comment.