Merge pull request #1193 from FarmBot/qa/9.2.2-rc8

Qa/9.2.2 rc8
pull/1197/head
Rick Carlino 2020-04-10 10:05:53 -05:00 committed by GitHub
commit fe2666e768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 18 deletions

View File

@ -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.

View File

@ -1 +1 @@
9.2.2-rc7
9.2.2-rc8

View File

@ -49,7 +49,7 @@ defmodule FarmbotCore.Asset.CriteriaRetriever do
needs_meta_filter = Repo.all(dynamic_query)
# There we go. We have all the matching %Point{}s
search_matches = search_meta_fields(pg, needs_meta_filter)
# ...but there are duplicates. We can remove them via uniq_by:
# ...but there are duplicates. We can remove them via uniq_by:
Enum.uniq_by((search_matches ++ always_ok), fn p -> p.id end)
end
@ -136,10 +136,10 @@ defmodule FarmbotCore.Asset.CriteriaRetriever do
if days == 0 do
{ pg, accum }
else
op = day_criteria["op"] || "<"
time = Timex.shift(Timex.now(), days: -1 * days)
{ pg, accum ++ [{"created_at", op, time}] }
end
end
@ -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
(_, {sql, ^count0}) -> {sql <> " ($#{count0},", count0+1}
(_, {sql, ^final}) -> {sql <> " $#{final})", final}
(_, {sql, count}) -> {sql <> " $#{count},", count+1}
end)
{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

View File

@ -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()

View File

@ -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()

View File

@ -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