mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
feat(tests): Add integration test for result error handling (#914)
* Add integration test * Fix test * Fix test
This commit is contained in:
parent
ca6cae96ad
commit
b2ca1d35bf
17
integration-tests/aqua/examples/handleResultError.aqua
Normal file
17
integration-tests/aqua/examples/handleResultError.aqua
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
aqua HandleResultError
|
||||||
|
|
||||||
|
export handleResultError
|
||||||
|
|
||||||
|
-- t = true, f = false
|
||||||
|
func handleResultError(t: bool, f: bool) -> string:
|
||||||
|
opt: ?[]string
|
||||||
|
|
||||||
|
if t == f: -- false
|
||||||
|
opt <<- ["unreachable"]
|
||||||
|
else:
|
||||||
|
opt <<- nil
|
||||||
|
|
||||||
|
result = opt!
|
||||||
|
|
||||||
|
-- should fail
|
||||||
|
<- result[0]
|
@ -16,6 +16,7 @@ import {
|
|||||||
seqOnPropagateCall,
|
seqOnPropagateCall,
|
||||||
} from "../examples/onErrorPropagation.js";
|
} from "../examples/onErrorPropagation.js";
|
||||||
import { errorClearCall } from "../examples/errorClear.js";
|
import { errorClearCall } from "../examples/errorClear.js";
|
||||||
|
import { handleResultErrorCall } from "../examples/handleResultError.js";
|
||||||
import { funcCall } from "../examples/funcCall.js";
|
import { funcCall } from "../examples/funcCall.js";
|
||||||
import { registerPrintln } from "../compiled/examples/println.js";
|
import { registerPrintln } from "../compiled/examples/println.js";
|
||||||
import { helloWorldCall } from "../examples/helloWorldCall.js";
|
import { helloWorldCall } from "../examples/helloWorldCall.js";
|
||||||
@ -756,6 +757,17 @@ describe("Testing examples", () => {
|
|||||||
expect(errorClearResult).toEqual(["handle", 0]);
|
expect(errorClearResult).toEqual(["handle", 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("handleResultError.aqua", async () => {
|
||||||
|
let call = handleResultErrorCall();
|
||||||
|
|
||||||
|
// js-client return string for interpretation error
|
||||||
|
// so matching with object guarantees that error was handled
|
||||||
|
expect(call).rejects.toMatchObject({
|
||||||
|
message: expect.stringContaining("0"),
|
||||||
|
error_code: expect.any(Number),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("complex.aqua", async () => {
|
it("complex.aqua", async () => {
|
||||||
let complexCallResult = await complexCall(selfPeerId, relayPeerId1);
|
let complexCallResult = await complexCall(selfPeerId, relayPeerId1);
|
||||||
expect(complexCallResult).toEqual([
|
expect(complexCallResult).toEqual([
|
||||||
|
5
integration-tests/src/examples/handleResultError.ts
Normal file
5
integration-tests/src/examples/handleResultError.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { handleResultError } from "../compiled/examples/handleResultError.js";
|
||||||
|
|
||||||
|
export async function handleResultErrorCall() {
|
||||||
|
return await handleResultError(true, false);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user