-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] no step function - [x] step run function - [x] step sleep function - [x] step sleep_until function - [x] step wait_for_event function - [x] fulfill - [x] timeout - [x] step send_event function --------- Co-authored-by: Darwin D Wu <[email protected]>
- Loading branch information
Showing
22 changed files
with
424 additions
and
36 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
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,28 @@ | ||
defmodule Inngest.Function.Cases.MultiStepTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
@default_sleep 5_000 | ||
|
||
@tag :integration | ||
test "should run successfully" do | ||
event_id = send_test_event("test/plug.step") | ||
Process.sleep(@default_sleep) | ||
|
||
assert {:ok, | ||
%{ | ||
"data" => [ | ||
%{ | ||
"output" => 5, | ||
"run_id" => _run_id, | ||
"status" => "Completed" | ||
} | ||
] | ||
}} = DevServer.run_ids(event_id) | ||
|
||
# TODO: check on step outputs | ||
# assert {:ok, resp} = DevServer.fn_run(run_id) |> IO.inspect() | ||
end | ||
end |
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,24 @@ | ||
defmodule Inngest.Function.Cases.NoStepTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
@default_sleep 5_000 | ||
|
||
@tag :integration | ||
test "should run successfully" do | ||
event_id = send_test_event("test/plug.no-step") | ||
Process.sleep(@default_sleep) | ||
|
||
assert {:ok, | ||
%{ | ||
"data" => [ | ||
%{ | ||
"output" => "hello world", | ||
"status" => "Completed" | ||
} | ||
] | ||
}} = DevServer.run_ids(event_id) | ||
end | ||
end |
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,30 @@ | ||
defmodule Inngest.Function.Cases.SendEventTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
@default_sleep 5_000 | ||
|
||
@tag :integration | ||
test "should run successfully" do | ||
event_id = send_test_event("test/plug.send") | ||
Process.sleep(@default_sleep) | ||
|
||
assert {:ok, | ||
%{ | ||
"data" => [ | ||
%{ | ||
"output" => %{ | ||
"event_ids" => event_ids | ||
}, | ||
"run_id" => _run_id, | ||
"status" => "Completed" | ||
} | ||
] | ||
}} = DevServer.run_ids(event_id) | ||
|
||
assert Enum.count(event_ids) > 0 | ||
assert is_list(event_ids) | ||
end | ||
end |
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,39 @@ | ||
defmodule Inngest.Function.Cases.SleepTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
@default_sleep 5_000 | ||
|
||
@tag :integration | ||
test "should run successfully" do | ||
event_id = send_test_event("test/plug.sleep") | ||
Process.sleep(@default_sleep) | ||
|
||
# it should be sleeping so have not completed | ||
assert {:ok, | ||
%{ | ||
"data" => [ | ||
%{ | ||
"run_id" => run_id, | ||
"status" => "Running", | ||
"ended_at" => nil | ||
} | ||
] | ||
}} = DevServer.run_ids(event_id) | ||
|
||
# wait till sleep is done | ||
Process.sleep(@default_sleep) | ||
|
||
assert {:ok, | ||
%{ | ||
"data" => %{ | ||
"event_id" => ^event_id, | ||
"run_id" => ^run_id, | ||
"output" => "yolo", | ||
"status" => "Completed" | ||
} | ||
}} = DevServer.fn_run(run_id) | ||
end | ||
end |
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,39 @@ | ||
defmodule Inngest.Function.Cases.SleepUntilTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
@default_sleep 5_000 | ||
|
||
@tag :integration | ||
test "should run successfully" do | ||
event_id = send_test_event("test/plug.sleep_until") | ||
Process.sleep(@default_sleep) | ||
|
||
# it should be sleeping so have not completed | ||
assert {:ok, | ||
%{ | ||
"data" => [ | ||
%{ | ||
"run_id" => run_id, | ||
"status" => "Running", | ||
"ended_at" => nil | ||
} | ||
] | ||
}} = DevServer.run_ids(event_id) | ||
|
||
# wait till sleep is done | ||
Process.sleep(@default_sleep) | ||
|
||
assert {:ok, | ||
%{ | ||
"data" => %{ | ||
"event_id" => ^event_id, | ||
"run_id" => ^run_id, | ||
"output" => "awake", | ||
"status" => "Completed" | ||
} | ||
}} = DevServer.fn_run(run_id) | ||
end | ||
end |
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,71 @@ | ||
defmodule Inngest.Function.Cases.WaitForEventTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
@default_sleep 5_000 | ||
|
||
@tag :integration | ||
test "should have access to event when fulfilled" do | ||
event_id = send_test_event("test/plug.wait-for-event") | ||
Process.sleep(@default_sleep) | ||
|
||
# it should be waiting | ||
assert {:ok, | ||
%{ | ||
"data" => [ | ||
%{ | ||
"run_id" => run_id, | ||
"status" => "Running", | ||
"ended_at" => nil | ||
} | ||
] | ||
}} = DevServer.run_ids(event_id) | ||
|
||
# send the waited event to continue | ||
assert _ = send_test_event("test/yolo.wait") | ||
Process.sleep(@default_sleep) | ||
|
||
assert {:ok, | ||
%{ | ||
"data" => %{ | ||
"event_id" => ^event_id, | ||
"run_id" => ^run_id, | ||
"output" => "fulfilled", | ||
"status" => "Completed" | ||
} | ||
}} = DevServer.fn_run(run_id) | ||
end | ||
|
||
@tag :integration | ||
test "should get nil when not fulfilled" do | ||
event_id = send_test_event("test/plug.wait-for-event") | ||
Process.sleep(@default_sleep) | ||
|
||
# it should be waiting | ||
assert {:ok, | ||
%{ | ||
"data" => [ | ||
%{ | ||
"run_id" => run_id, | ||
"status" => "Running", | ||
"ended_at" => nil | ||
} | ||
] | ||
}} = DevServer.run_ids(event_id) | ||
|
||
# Don't do anything | ||
Process.sleep(@default_sleep) | ||
|
||
assert {:ok, | ||
%{ | ||
"data" => %{ | ||
"event_id" => ^event_id, | ||
"run_id" => ^run_id, | ||
"output" => "empty", | ||
"status" => "Completed" | ||
} | ||
}} = DevServer.fn_run(run_id) | ||
end | ||
end |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.