Combine Laptop Genserver examples to avoid process leaking issue

This commit is contained in:
Jay Hayes
2022-02-01 07:53:51 -06:00
parent ad5952c7ab
commit 20927cc1df
2 changed files with 3 additions and 8 deletions

View File

@@ -135,15 +135,11 @@ defmodule GenServers do
koan "Our server works but it's pretty ugly to use; so lets use a cleaner interface" do koan "Our server works but it's pretty ugly to use; so lets use a cleaner interface" do
Laptop.start_link("EL!73") Laptop.start_link("EL!73")
assert Laptop.unlock("EL!73") == ___
end
koan "Let's use the remaining functions in the external API" do assert Laptop.unlock("EL!73") == ___
Laptop.start_link("EL!73")
{_, response} = Laptop.unlock("EL!73")
assert response == ___
Laptop.change_password("EL!73", "Elixir") Laptop.change_password("EL!73", "Elixir")
{_, response} = Laptop.unlock("EL!73") {_, response} = Laptop.unlock("EL!73")
assert response == ___ assert response == ___

View File

@@ -11,8 +11,7 @@ defmodule GenServersTests do
"73x7!n9", "73x7!n9",
{:error, "Incorrect password!"}, {:error, "Incorrect password!"},
"Congrats! Your process was successfully named.", "Congrats! Your process was successfully named.",
{:ok, "Laptop unlocked!"}, {:multiple, [{:ok, "Laptop unlocked!"}, "Incorrect password!", "Jack Sparrow"]}
{:multiple, ["Laptop unlocked!", "Incorrect password!", "Jack Sparrow"]}
] ]
test_all(GenServers, answers) test_all(GenServers, answers)