-
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.
Co-authored-by: Darwin D Wu <darwin67@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
194 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
defmodule Inngest.Function.Cases.BatchEventsTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
# TODO: Add test after moving batching logic to OSS | ||
# alias Inngest.Test.DevServer | ||
# import Inngest.Test.Helper | ||
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,36 @@ | ||
defmodule Inngest.Function.Cases.RateLimitTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Inngest.Test.DevServer | ||
import Inngest.Test.Helper | ||
|
||
@default_sleep 10_000 | ||
|
||
@tag :integration | ||
test "should only run 2 out of 10" do | ||
event_ids = Enum.map(1..10, fn _ -> send_test_event("test/plug.ratelimit") end) | ||
|
||
Process.sleep(@default_sleep) | ||
|
||
fn_runs = | ||
event_ids | ||
|> Enum.map(fn id -> | ||
{:ok, %{"data" => data}} = DevServer.run_ids(id) | ||
|
||
if Enum.count(data) == 1 do | ||
assert [ | ||
%{ | ||
"output" => "Rate Limited", | ||
"status" => "Completed", | ||
"run_id" => run_id | ||
Check warning on line 25 in test/inngest/function/cases/rate_limit_test.exs GitHub Actions / Test (Elixir 1.14 / OTP 24.3)
Check warning on line 25 in test/inngest/function/cases/rate_limit_test.exs GitHub Actions / Test (Elixir 1.14 / OTP 25.3)
Check warning on line 25 in test/inngest/function/cases/rate_limit_test.exs GitHub Actions / Test (Elixir 1.15 / OTP 24.3)
|
||
} | ||
] = data | ||
else | ||
nil | ||
end | ||
end) | ||
|> Enum.filter(&(!is_nil(&1))) | ||
|
||
assert Enum.count(fn_runs) <= 2 | ||
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 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,21 @@ | ||
defmodule Inngest.Test.Case.RateLimitFn do | ||
@moduledoc false | ||
|
||
use Inngest.Function | ||
alias Inngest.{FnOpts, Trigger} | ||
|
||
@func %FnOpts{ | ||
id: "ratelimit-fn", | ||
name: "RateLimit Function", | ||
rate_limit: %{ | ||
limit: 2, | ||
period: "5s" | ||
} | ||
} | ||
@trigger %Trigger{event: "test/plug.ratelimit"} | ||
|
||
@impl true | ||
def exec(_ctx, _args) do | ||
{:ok, "Rate Limited"} | ||
end | ||
end |