Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make most tests run async #576

Merged
merged 3 commits into from
Jul 17, 2023
Merged

make most tests run async #576

merged 3 commits into from
Jul 17, 2023

Conversation

mat-hek
Copy link
Member

@mat-hek mat-hek commented Jul 12, 2023

No description provided.

@mat-hek mat-hek requested a review from FelonEkonom July 12, 2023 12:06
@mat-hek mat-hek added the no-changelog This label has to be added if changes from the PR are not meant to be placed in the CHANGELOG.md label Jul 12, 2023
Comment on lines 1 to 23
defmodule Membrane.ClockTest.Sync do
use ExUnit.Case, async: false

@module Membrane.Clock

@initial_ratio Ratio.new(1)

test "should send proper ratio when default time provider is used" do
ratio_error = 0.3
{:ok, clock} = @module.start_link()
@module.subscribe(clock)
assert_receive {:membrane_clock_ratio, ^clock, @initial_ratio}
send(clock, {:membrane_clock_update, 100})
Process.send_after(clock, {:membrane_clock_update, 100}, 50)
Process.send_after(clock, {:membrane_clock_update, random_time()}, 100)
assert_receive {:membrane_clock_ratio, ^clock, ratio}
assert_in_delta Ratio.to_float(ratio), 100 / 50, ratio_error
assert_receive {:membrane_clock_ratio, ^clock, ratio}
assert_in_delta Ratio.to_float(ratio), 100 / 50, ratio_error
end

defp random_time, do: :rand.uniform(10_000)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is not nice to have modules Membrane.ClockTest.Sync and Membrane.ClockTest on the same level in file named clock_test.exs

@mat-hek mat-hek requested a review from FelonEkonom July 13, 2023 14:13
@mat-hek mat-hek merged commit 034e2a5 into master Jul 17, 2023
1 check passed
@mat-hek mat-hek deleted the async-tests branch July 17, 2023 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog This label has to be added if changes from the PR are not meant to be placed in the CHANGELOG.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants