Test case: Missing paramters and falling back to defaults- FE=>Regimen=>Sequence

pull/974/head
Rick Carlino 2019-03-28 11:27:14 -05:00 committed by Connor Rigby
parent fd2ab792dd
commit 8aeac940f6
No known key found for this signature in database
GPG Key ID: 29A88B24B70456E0
1 changed files with 81 additions and 0 deletions

View File

@ -230,6 +230,87 @@ defmodule FarmbotCore.FarmEventWorkerTest do
{:ok, _} = FarmbotCore.AssetWorker.FarmbotCore.Asset.FarmEvent.start_link(farm_event, [])
assert_receive {:move_absolute, [8000, 8000, 8000, 100]}, 5_000
end
test "Missing parameters, FarmEvent => Regimen => Sequence" do
sequence =
sequence(%{
args: %{
locals: %{
kind: "scope_declaration",
args: %{},
body: [
%{
kind: "parameter_declaration",
args: %{
label: "from_regimen",
default_value: %{
kind: "coordinate",
args: %{x: -1, y: -2, z: -3}
}
}
}
]
}
},
body: [
%{
kind: "move_absolute",
args: %{
location: %{
kind: "identifier",
args: %{
label: "from_regimen"
}
},
offset: %{
kind: "coordinate",
args: %{x: 0, y: 0, z: 0}
},
speed: 100
}
}
]
})
now = DateTime.utc_now()
{:ok, epoch} = RegimenInstance.build_epoch(now)
offset = Timex.diff(now, epoch, :milliseconds) + 500
regimen =
regimen(%{
regimen_items: [%{time_offset: offset, sequence_id: sequence.id}],
body: []
})
start_time = Timex.shift(now, minutes: -20)
end_time = Timex.shift(now, minutes: 10)
params = %{
start_time: start_time,
end_time: end_time,
repeat: 1,
time_unit: "never",
body: []
}
farm_event = regimen_event(regimen, params)
that = self()
{:ok, _} = TestSysCalls.checkout()
:ok =
TestSysCalls.handle(TestSysCalls, fn
:coordinate, [x, y, z] ->
%{x: x, y: y, z: z}
kind, args ->
send(that, {kind, args})
:ok
end)
{:ok, _} = FarmbotCore.AssetWorker.FarmbotCore.Asset.FarmEvent.start_link(farm_event, [])
assert_receive {:move_absolute, [-1, -2, -3, 100]}, 5_000
end
end
describe "common" do