commit
fe2666e768
|
@ -1,5 +1,14 @@
|
|||
# Changelog
|
||||
|
||||
# 9.2.2
|
||||
|
||||
* Fix firmware locking error ("Can't perform X in Y state")
|
||||
* Removal of dead code / legacy plus numerous unit test additions.
|
||||
* Added coveralls test coverage reporter
|
||||
* Unit test additions (+2.7% coverage :tada:)
|
||||
* Updates to build instructions for third party developers
|
||||
* Bug fix for criteria-based groups that have only one filter criteria.
|
||||
|
||||
# 9.2.1
|
||||
|
||||
* Improve firmware debug messages.
|
||||
|
|
|
@ -159,14 +159,19 @@ defmodule FarmbotCore.Asset.CriteriaRetriever do
|
|||
# NOT OK: Repo.query("SELECT foo WHERE bar IN $0", [[1, 2, 3]])
|
||||
# OK: Repo.query("SELECT foo WHERE bar IN ($0, $1, $2)", [1, 2, 3])
|
||||
defp stage_3({sql, args}, {full_query, full_args, count0}) when is_list(args) do
|
||||
final = count0 + Enum.count(args) - 1
|
||||
arg_count = Enum.count(args)
|
||||
final = count0 + (arg_count - 1)
|
||||
initial_state = {sql, count0}
|
||||
{next_sql, _} = Enum.reduce(args, initial_state, fn
|
||||
{next_sql, _} =
|
||||
if arg_count == 1 do
|
||||
{sql <> " ($#{count0})", nil}
|
||||
else
|
||||
Enum.reduce(args, initial_state, fn
|
||||
(_, {sql, ^count0}) -> {sql <> " ($#{count0},", count0+1}
|
||||
(_, {sql, ^final}) -> {sql <> " $#{final})", final}
|
||||
(_, {sql, count}) -> {sql <> " $#{count},", count+1}
|
||||
end)
|
||||
|
||||
end
|
||||
{full_query ++ [next_sql], full_args ++ [args], final + 1}
|
||||
end
|
||||
|
||||
|
|
|
@ -24,6 +24,23 @@ defmodule FarmbotCore.Asset.CriteriaRetrieverTest do
|
|||
}
|
||||
}
|
||||
|
||||
@simple_point_group %PointGroup{
|
||||
point_ids: [],
|
||||
sort_type: "xy_ascending",
|
||||
criteria: %{
|
||||
"day" => %{
|
||||
"op" => "<",
|
||||
"days_ago" => 0
|
||||
},
|
||||
"string_eq" => %{
|
||||
"pointer_type" => ["Plant"]
|
||||
},
|
||||
"number_eq" => %{},
|
||||
"number_lt" => %{},
|
||||
"number_gt" => %{}
|
||||
}
|
||||
}
|
||||
|
||||
# Use this is a fake "Timex.now()" value when mocking.
|
||||
@now ~U[2222-12-10 02:22:22.222222Z]
|
||||
@five_days_ago ~U[2222-12-05 01:11:11.111111Z]
|
||||
|
@ -90,6 +107,19 @@ defmodule FarmbotCore.Asset.CriteriaRetrieverTest do
|
|||
pg
|
||||
end
|
||||
|
||||
test "direct match on `pointer_type` via `string_eq`" do
|
||||
Repo.delete_all(PointGroup)
|
||||
Repo.delete_all(Point)
|
||||
|
||||
point!(%{id: 1, pointer_type: "Plant"})
|
||||
point!(%{id: 2, pointer_type: "Weed"})
|
||||
point!(%{id: 3, pointer_type: "ToolSlot"})
|
||||
point!(%{id: 4, pointer_type: "GenericPointer"})
|
||||
|
||||
result = CriteriaRetriever.run(@simple_point_group)
|
||||
assert Enum.count(result) == 1
|
||||
end
|
||||
|
||||
test "run/1" do
|
||||
expect(Timex, :now, fn -> @now end)
|
||||
pg = point_group_with_fake_points()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
defmodule FarmbotCore.ProjectTest do
|
||||
use ExUnit.Case
|
||||
@opts [cd: Path.join("c_src", "farmbot-arduino-firmware")]
|
||||
# @opts [cd: Path.join("c_src", "farmbot-arduino-firmware")]
|
||||
|
||||
test "arduino_commit" do
|
||||
actual = FarmbotCore.Project.arduino_commit()
|
||||
|
|
|
@ -22,14 +22,14 @@ defmodule FarmbotOS.Lua.Ext.FirmwareTest do
|
|||
lua = "return"
|
||||
|
||||
expect(FarmbotCeleryScript.SysCalls, :move_absolute, 4, fn
|
||||
(1, _, _, _) -> :ok
|
||||
(_, _, _, _) -> {:error, msg}
|
||||
1, _, _, _ -> :ok
|
||||
_, _, _, _ -> {:error, msg}
|
||||
end)
|
||||
|
||||
assert {[true], ^lua} = Firmware.move_absolute([1,2,3,4], lua)
|
||||
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5,6,7,8], lua)
|
||||
assert {[true], ^lua} = Firmware.move_absolute([1,2,3], lua)
|
||||
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5,6,7], lua)
|
||||
assert {[true], ^lua} = Firmware.move_absolute([1, 2, 3, 4], lua)
|
||||
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5, 6, 7, 8], lua)
|
||||
assert {[true], ^lua} = Firmware.move_absolute([1, 2, 3], lua)
|
||||
assert {[nil, ^msg], ^lua} = Firmware.move_absolute([5, 6, 7], lua)
|
||||
end
|
||||
|
||||
test "find_home/2" do
|
||||
|
|
Loading…
Reference in New Issue