-
Notifications
You must be signed in to change notification settings - Fork 11
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
Get Coverage to 100% #3
Conversation
Changes Unknown when pulling 2f9b20c on kinson:master into ** on simonewebdesign:master**. |
This is still in progress obviously. I have a couple of questions so far.
Thanks for your patience and guidance on this, I am sure you could probably do this yourself in less time than it takes to explain it to me! |
Changes Unknown when pulling 39c538b on kinson:master into ** on simonewebdesign:master**. |
Changes Unknown when pulling b37aec8 on kinson:master into ** on simonewebdesign:master**. |
Changes Unknown when pulling 877325e on kinson:master into ** on simonewebdesign:master**. |
Changes Unknown when pulling 5bbdb3c on kinson:master into ** on simonewebdesign:master**. |
Hey @kinson, thanks for this PR! Sorry I haven't found the time to review it yet — will do it soon! |
Hey @simonewebdesign no worries at all! There are definitely some places that I want to polish before this gets merged, I'll go ahead and make a few comments on the specific code. |
lib/pub_sub.ex
Outdated
iex> pid = self() | ||
iex> PubSub.subscribe(pid, :my_topic) | ||
iex> PubSub.subscribers(:my_topic) |> Enum.count | ||
1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't very explicit. In reality PubSub.subscribers
returns [#PID<123.1>] or something like that but I am unsure of how to match against the pid type in an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum.count
is good enough, but this would be better:
iex> pid = self()
iex> PubSub.subscribe(pid, :my_topic)
iex> [subscriber] = PubSub.subscribers(:my_topic)
iex> subscriber == pid
true
test/pub_sub_test.exs
Outdated
assert Process.exit(pid, :kill) == true | ||
# shouldn't all subscribers be deleted, making this 0? | ||
# IO.inspect PubSub.subscribers(:my_topic) | ||
assert PubSub.subscribers(:my_topic) |> Enum.count == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure why the subscribers list still includes the killed off pid here
test/pub_sub_test.exs
Outdated
pid = spawn(fn -> | ||
receive do | ||
message -> | ||
assert message == "Hello!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this is being reached, unsure of how to assert that this subscriber received the message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what you're looking for: https://hexdocs.pm/ex_unit/ExUnit.Assertions.html#assert_received/2
Changes Unknown when pulling 2c6f8f3 on kinson:master into ** on simonewebdesign:master**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a few minor comments, but looks great! Well done!
lib/pub_sub.ex
Outdated
iex> pid = self() | ||
iex> PubSub.subscribe(pid, :my_topic) | ||
iex> PubSub.subscribers(:my_topic) |> Enum.count | ||
1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum.count
is good enough, but this would be better:
iex> pid = self()
iex> PubSub.subscribe(pid, :my_topic)
iex> [subscriber] = PubSub.subscribers(:my_topic)
iex> subscriber == pid
true
mix.lock
Outdated
"mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, | ||
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []}, | ||
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []}, | ||
"unicode_util_compat": {:hex, :unicode_util_compat, "0.2.0", "dbbccf6781821b1c0701845eaf966c9b6d83d7c3bfc65ca2b78b88b8678bfa35", [:rebar3], []}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you unstage this file please?
test/pub_sub_test.exs
Outdated
|
||
assert Process.exit(pid, :kill) == true | ||
ref = Process.monitor(pid) | ||
assert_receive {:DOWN, ^ref, _, _, _} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably use assert_down
here as well?
test/pub_sub_test.exs
Outdated
pid = spawn(fn -> | ||
receive do | ||
message -> | ||
assert message == "Hello!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what you're looking for: https://hexdocs.pm/ex_unit/ExUnit.Assertions.html#assert_received/2
Changes Unknown when pulling a554746 on kinson:master into ** on simonewebdesign:master**. |
Changes Unknown when pulling 24a6689 on kinson:master into ** on simonewebdesign:master**. |
Still having issues with |
Alright I was able to successfully use |
Changes Unknown when pulling 13cb163 on kinson:master into ** on simonewebdesign:master**. |
It's more than enough, thanks! Just squash all the commits in one and I'll merge your PR 👍 |
Everything should be squashed! 👍 |
Changes Unknown when pulling 81adcd6 on kinson:master into ** on simonewebdesign:master**. |
Thanks again for your guidance on this! |
Addressing #2