format_float(nil), test updates

pull/1164/head
Rick Carlino 2020-03-04 10:50:18 -06:00
parent 6b4290f77c
commit 4bd6a44afc
4 changed files with 18 additions and 4 deletions

View File

@ -1,5 +1,5 @@
defmodule FarmbotCeleryScript.FormatUtil do
# def format_float(nil), do: nil
def format_float(nil), do: nil
def format_float(value) when is_integer(value) do
format_float(value / 1)

View File

@ -1,14 +1,23 @@
defmodule FarmbotOS.SysCalls.ResourceUpdateTest do
use ExUnit.Case
use Mimic
alias FarmbotOS.SysCalls.ResourceUpdate
alias FarmbotOS.SysCalls.PointLookup
alias FarmbotCore.Asset.{Point, Repo}
setup :verify_on_exit!
def fake_coords! do
expect(FarmbotOS.SysCalls, :get_cached_position, fn ->
[x: 1.2, y: 2.3, z: 3.4]
end)
end
test "resource_update/3 - Device" do
fake_coords!
params = %{name: "X is {{ x }}"}
assert :ok == ResourceUpdate.resource_update("Device", 0, params)
assert "X is -1" == FarmbotCore.Asset.device().name
assert "X is 1.2" == FarmbotCore.Asset.device().name
end
test "resource_update/3 - Point" do
@ -21,7 +30,7 @@ defmodule FarmbotOS.SysCalls.ResourceUpdateTest do
params = %{name: "Updated to {{ x }}"}
assert :ok == ResourceUpdate.resource_update("Plant", 555, params)
next_plant = PointLookup.point("Plant", 555)
assert "Updated to -1" == next_plant.name
assert "Updated to " == next_plant.name
bad_result1 = ResourceUpdate.resource_update("Plant", 0, params)
error = "Plant.0 is not currently synced, so it could not be updated"

View File

@ -7,8 +7,12 @@ defmodule FarmbotOS.SysCalls.SendMessageTest do
alias FarmbotOS.SysCalls.SendMessage
test "send_message" do
expect(FarmbotOS.SysCalls, :get_cached_position, fn ->
[x: 1.2, y: 2.3, z: 3.4]
end)
expect(FarmbotCore.LogExecutor, :execute, 1, fn log ->
assert log.message == "You are here: -1, -1, -1"
assert log.message == "You are here: 1.2, 2.3, 3.4"
end)
channels = [:email]

View File

@ -14,6 +14,7 @@ Mimic.copy(FarmbotOS.Configurator.ConfigDataLayer)
Mimic.copy(FarmbotOS.Configurator.DetsTelemetryLayer)
Mimic.copy(FarmbotOS.Configurator.FakeNetworkLayer)
Mimic.copy(FarmbotOS.SysCalls.Movement)
Mimic.copy(FarmbotOS.SysCalls)
Mimic.copy(File)
Mimic.copy(MuonTrap)
ExUnit.start()