Renamed start_server/1 to start_link/1 and updated a password.

This commit is contained in:
Eric Anderson
2017-07-15 00:49:52 -05:00
parent 78d0181cce
commit cb98ca1c52
2 changed files with 5 additions and 5 deletions

View File

@@ -9,7 +9,7 @@ defmodule GenServers do
##### #####
# External API # External API
def start_server(init_password) do def start_link(init_password) do
# The __MODULE__ macro returns the current module name as an atom # The __MODULE__ macro returns the current module name as an atom
GenServer.start_link(__MODULE__, init_password, name: __MODULE__) GenServer.start_link(__MODULE__, init_password, name: __MODULE__)
end end
@@ -78,7 +78,7 @@ defmodule GenServers do
end end
koan "When starting a GenServer you can set it's initial state" do koan "When starting a GenServer you can set it's initial state" do
{:ok, pid} = GenServer.start_link(BicycleLock, "Hey Arnold!") {:ok, pid} = GenServer.start_link(BicycleLock, "3kr3t!")
assert GenServer.call(pid, :get_password) == ___ assert GenServer.call(pid, :get_password) == ___
end end
@@ -118,12 +118,12 @@ defmodule GenServers do
end end
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
BicycleLock.start_server("EL!73") BicycleLock.start_link("EL!73")
assert BicycleLock.unlock("EL!73") == ___ assert BicycleLock.unlock("EL!73") == ___
end end
koan "Let's use the remaining functions in the external API" do koan "Let's use the remaining functions in the external API" do
BicycleLock.start_server("EL!73") BicycleLock.start_link("EL!73")
{_, response} = BicycleLock.unlock("EL!73") {_, response} = BicycleLock.unlock("EL!73")
assert response == ___ assert response == ___

View File

@@ -5,7 +5,7 @@ defmodule GenServersTests do
test "GenServers" do test "GenServers" do
answers = [ answers = [
true, true,
"Hey Arnold!", "3kr3t!",
"3kr3t!", "3kr3t!",
{:multiple, ["Tribe Bicycle Co.", "CRMO Series"]}, {:multiple, ["Tribe Bicycle Co.", "CRMO Series"]},
{:multiple, [["this", "is", "sparta"], 369, :hello_world]}, {:multiple, [["this", "is", "sparta"], 369, :hello_world]},