(44.4%) Finish tests FarmbotOS.SysCalls.ResourceUpdate

pull/1153/head
Rick Carlino 2020-02-17 16:26:06 -06:00
parent 4918a75b62
commit 1cde334792
2 changed files with 29 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"coverage_options": {
"treat_no_relevant_lines_as_covered": true,
"minimum_coverage": 39
"minimum_coverage": 44
}
}

View File

@ -2,10 +2,38 @@ defmodule FarmbotOS.SysCalls.ResourceUpdateTest do
use ExUnit.Case
alias FarmbotOS.SysCalls.ResourceUpdate
alias FarmbotOS.SysCalls.PointLookup
alias FarmbotCore.Asset.{
Point,
Repo,
}
test "resource_update/3 - Device" do
params = %{name: "X is {{ x }}"}
assert :ok == ResourceUpdate.resource_update("Device", 0, params)
assert "X is -1" == FarmbotCore.Asset.device().name
end
test "resource_update/3 - Point" do
Repo.delete_all(Point)
%Point{id: 555, pointer_type: "Plant"}
|> Point.changeset()
|> Repo.insert!()
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
bad_result1 = ResourceUpdate.resource_update("Plant", 0, params)
error = "Plant.0 is not currently synced, so it could not be updated"
assert {:error, error} == bad_result1
end
test "resource_update/3 - unknown" do
params = %{name: "never called"}
{:error, error } = ResourceUpdate.resource_update("Foo", 0, nil)
assert error == "Unknown resource: Foo.0\n"
end
end