Add fake upgrade mock

This commit is contained in:
connor rigby 2018-01-09 10:32:30 -08:00
parent 00898e00a0
commit 8ca7768599
4 changed files with 19 additions and 2 deletions

View file

@ -16,7 +16,7 @@ config :farmbot, :init, [
Farmbot.Host.Bootstrap.Configurator,
Farmbot.Host.TargetConfiguratorTest.Supervisor,
Farmbot.System.Udev.Supervisor,
# Farmbot.System.Debug
Farmbot.System.Debug
]
# Transports.

View file

@ -58,6 +58,22 @@ defmodule Farmbot.System.DebugRouter do
end
end
get "/api/release_mock.json" do
file = "#{:code.priv_dir(:farmbot)}/debug/templates/release_mock.json.eex"
url = "http://#{conn.host}:#{conn.port}/api/release_mock.json"
tag_name = conn.params["tag_name"] || "v#{Farmbot.Project.version()}"
target_commitish = conn.params["target_commitish"] || Farmbot.Project.commit
body = conn.params["body"] || "This is a fake release"
File.cp "_build/rpi3/prod/nerves/images/farmbot-signed.fw", "#{:code.priv_dir(:farmbot)}/debug/static/farmbot-rpi3-#{tag_name}.fw"
fw_asset_url = conn.params["fw_asset_url"] || "http://#{conn.host}:#{conn.port}/farmbot-rpi3-#{tag_name}.fw"
resp = EEx.eval_file(file, [url: url, fw_asset_url: fw_asset_url, tag_name: tag_name, target_commitish: target_commitish, body: body])
conn
|> put_resp_header("content-type", "Application/JSON")
|> send_resp(200, resp)
end
match(_, do: send_resp(conn, 404, "Page not found"))
defp make_html(file) do

View file

@ -109,7 +109,7 @@ defmodule Farmbot.Mixfile do
{:cowboy, "~> 1.1"},
{:plug, "~> 1.4"},
{:cors_plug, "~> 1.2"},
{:wobserver, "~> 0.1.8", only: [:dev, :test]},
{:wobserver, "~> 0.1.8"},
{:rsa, "~> 0.0.1"},
{:joken, "~> 1.1"},

View file

@ -8,3 +8,4 @@
!templates/*
!styles.css
!favicon.ico
*.fw