Tests for /finish. TODO: Remove :telemetry_layer config references.

pull/1135/head
Rick Carlino 2020-02-05 15:27:23 -06:00
parent a248d98f83
commit c8e289409c
2 changed files with 28 additions and 0 deletions

View File

@ -271,6 +271,11 @@ defmodule FarmbotOS.Configurator.Router do
get "/finish" do
FarmbotCore.Logger.debug(1, "Configuration complete")
# TODO(Rick): This pattern match is not 100% accurate.
# TO see what I mean, try calling `save_config/1` with
# _only_ the parameters provided in the line below-
# it will crash as it is missing numerous keys.
# It might be good to add an error page or something.
case get_session(conn) do
%{
"ifname" => _,

View File

@ -1,5 +1,7 @@
defmodule FarmbotOS.Configurator.RouterTest do
alias FarmbotOS.Configurator.Router
alias FarmbotOS.Configurator.ConfigDataLayer
use ExUnit.Case, async: true
use Plug.Test
@ -397,4 +399,25 @@ defmodule FarmbotOS.Configurator.RouterTest do
assert(is_binary(zero["timestamp"]))
assert(is_integer(zero["value"]))
end
test "/finish" do
expect(ConfigDataLayer, :save_config, 1, fn conf ->
:ok
end)
kon =
conn(:get, "/finish")
|> init_test_session(%{
"ifname" => "MY_IFNAME",
"auth_config_email" => "MY_EMAIL",
"auth_config_password" => "MY_PASS",
"auth_config_server" => "MY_SERVER"
})
|> Router.call(@opts)
assert String.contains?(
kon.resp_body,
"If any configuration settings are incorrect, FarmBot will reset"
)
end
end