From 796d0c8ef478b06952f3c925ef4aec0980b46e14 Mon Sep 17 00:00:00 2001 From: Adrian Kumpf <8999358+adriankumpf@users.noreply.github.com> Date: Fri, 24 Sep 2021 21:35:29 +0200 Subject: [PATCH] Update phoenix to 1.6.0 --- .gitignore | 9 +- assets/package.json | 2 +- config/test.exs | 2 + mix.exs | 2 +- mix.lock | 2 +- test/support/conn_case.ex | 13 +- test/support/data_case.ex | 14 +- test/support/vehicle_case.ex | 284 +++++++++--------- test/teslamate/import_test.exs | 37 ++- .../vehicles/identification_test.exs | 1 - .../vehicles/vehicle/charging_sync_test.exs | 4 +- .../vehicles/vehicle/charging_test.exs | 1 + .../vehicles/vehicle/driving_test.exs | 3 +- .../vehicles/vehicle/streaming_test.exs | 4 +- .../vehicles/vehicle/suspend_logging_test.exs | 3 +- .../vehicles/vehicle/suspend_test.exs | 2 +- .../vehicles/vehicle/updating_test.exs | 2 + test/teslamate/vehicles/vehicle_sync_test.exs | 4 +- test/teslamate/vehicles/vehicle_test.exs | 10 +- test/teslamate/vehicles_test.exs | 6 +- .../live/car_index_live_test.exs | 1 - .../live/charge_cost_live_test.exs | 5 +- 22 files changed, 222 insertions(+), 189 deletions(-) diff --git a/.gitignore b/.gitignore index 00595957..953492c8 100644 --- a/.gitignore +++ b/.gitignore @@ -28,10 +28,11 @@ npm-debug.log # The directory NPM downloads your dependencies sources to. /assets/node_modules/ -# Since we are building assets from assets/, -# we ignore priv/static. You may want to comment -# this depending on your deployment strategy. -/priv/static/assets +# Ignore assets that are produced by build tools. +/priv/static/assets/ + +# Ignore digested assets cache. +/priv/static/cache_manifest.json # CDLR data repository /priv/cldr/ diff --git a/assets/package.json b/assets/package.json index e664a603..c8ed1e6a 100644 --- a/assets/package.json +++ b/assets/package.json @@ -19,7 +19,7 @@ }, "devDependencies": { "bulma": "^0.9.3", - "esbuild": "^0.13.1", + "esbuild": "^0.13.2", "esbuild-sass-plugin": "^1.5.5", "sass": "^1.42.1" }, diff --git a/config/test.exs b/config/test.exs index 23fce62a..d53d3369 100644 --- a/config/test.exs +++ b/config/test.exs @@ -6,3 +6,5 @@ config :logger, level: :warning # you can enable the server option below. config :teslamate, TeslaMateWeb.Endpoint, server: false config :teslamate, TeslaMate.Repo, pool: Ecto.Adapters.SQL.Sandbox + +config :phoenix, :plug_init_mode, :runtime diff --git a/mix.exs b/mix.exs index 78aaf3ca..80b3ef6c 100644 --- a/mix.exs +++ b/mix.exs @@ -47,7 +47,7 @@ defmodule TeslaMate.MixProject do {:jason, "~> 1.0"}, {:mock, "~> 0.3", only: :test}, {:nimble_csv, "~> 1.1"}, - {:phoenix, "~> 1.6.0-rc", override: true}, + {:phoenix, "~> 1.6.0"}, {:phoenix_ecto, "~> 4.0"}, {:phoenix_html, "~> 3.0"}, {:phoenix_live_reload, "~> 1.2", only: :dev}, diff --git a/mix.lock b/mix.lock index dd506fe2..42c63c4a 100644 --- a/mix.lock +++ b/mix.lock @@ -33,7 +33,7 @@ "nimble_options": {:hex, :nimble_options, "0.3.7", "1e52dd7673d36138b1a5dede183b5d86dff175dc46d104a8e98e396b85b04670", [:mix], [], "hexpm", "2086907e6665c6b6579be54ef5001928df5231f355f71ed258f80a55e9f63633"}, "nimble_pool": {:hex, :nimble_pool, "0.2.4", "1db8e9f8a53d967d595e0b32a17030cdb6c0dc4a451b8ac787bf601d3f7704c3", [:mix], [], "hexpm", "367e8071e137b787764e6a9992ccb57b276dc2282535f767a07d881951ebeac6"}, "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, - "phoenix": {:hex, :phoenix, "1.6.0-rc.1", "e47638ecdc87392deef6c37cafa77ed5d4a495751dab173ad6935cb4eb6a8dda", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0170b61d669e0743a0dcadd0ef0448f1a8f66b183e9b59788ad2703d853e963d"}, + "phoenix": {:hex, :phoenix, "1.6.0", "7b85023f7ddef9a5c70909a51cc37c8b868b474d853f90f4280efd26b0e7cce5", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "52ffdd31f2daeb399b2e1eb57d468f99a1ad6eee5d8ea19d2353492f06c9fc96"}, "phoenix_ecto": {:hex, :phoenix_ecto, "4.4.0", "0672ed4e4808b3fbed494dded89958e22fb882de47a97634c0b13e7b0b5f7720", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "09864e558ed31ee00bd48fcc1d4fc58ae9678c9e81649075431e69dbabb43cc1"}, "phoenix_html": {:hex, :phoenix_html, "3.0.4", "232d41884fe6a9c42d09f48397c175cd6f0d443aaa34c7424da47604201df2e1", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "ce17fd3cf815b2ed874114073e743507704b1f5288bb03c304a77458485efc8b"}, "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"}, diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index c271abb7..e3bf47d6 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -31,10 +31,15 @@ defmodule TeslaMateWeb.ConnCase do end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(TeslaMate.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(TeslaMate.Repo, {:shared, self()}) + try do + pid = Ecto.Adapters.SQL.Sandbox.start_owner!(TeslaMate.Repo, shared: not tags[:async]) + on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) + rescue + e in [MatchError] -> + case e.term do + {:error, {{:badmatch, :already_shared}, _}} -> :ok + _ -> reraise e, __STACKTRACE__ + end end # Start the Endpoint manually since tests run with '--no-start' diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 8720aa3b..bbd889c1 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -26,13 +26,15 @@ defmodule TeslaMate.DataCase do end setup tags do - :ok = Ecto.Adapters.SQL.Sandbox.checkout(TeslaMate.Repo) - - unless tags[:async] do - Ecto.Adapters.SQL.Sandbox.mode(TeslaMate.Repo, {:shared, self()}) - end - + pid = Ecto.Adapters.SQL.Sandbox.start_owner!(TeslaMate.Repo, shared: not tags[:async]) + on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) :ok + rescue + e in [MatchError] -> + case e.term do + {:error, {{:badmatch, :already_shared}, _}} -> :ok + _ -> reraise e, __STACKTRACE__ + end end @doc """ diff --git a/test/support/vehicle_case.ex b/test/support/vehicle_case.ex index 747fc794..8e2092eb 100644 --- a/test/support/vehicle_case.ex +++ b/test/support/vehicle_case.ex @@ -3,145 +3,157 @@ defmodule TeslaMate.VehicleCase do using do quote do - alias TeslaMate.Vehicles.Vehicle.Summary - alias TeslaMate.Vehicles.Vehicle - alias TeslaMate.Settings.CarSettings - alias TeslaMate.Log.{Car, Update} - alias TeslaApi.Vehicle.State - import Ecto import Ecto.Changeset import Ecto.Query - - def start_vehicle(name, events, opts \\ []) when length(events) > 0 do - mock_log? = Keyword.get(opts, :log, true) - last = Keyword.get(opts, :last_update, %Update{version: "9999.99.99.0 lasjas234"}) - - log_name = :"log_#{name}" - api_name = :"api_#{name}" - settings_name = :"settings_#{name}" - locations_name = :"locations_#{name}" - vehicles_name = :"vehicles_#{name}" - pubsub_name = :"pubsub_#{name}" - - {:ok, _pid} = start_supervised({LogMock, name: log_name, pid: self(), last_update: last}) - {:ok, _pid} = start_supervised({ApiMock, name: api_name, events: events, pid: self()}) - {:ok, _pid} = start_supervised({SettingsMock, name: settings_name, pid: self()}) - {:ok, _pid} = start_supervised({VehiclesMock, name: vehicles_name, pid: self()}) - {:ok, _pid} = start_supervised({PubSubMock, name: pubsub_name, pid: self()}) - {:ok, _pid} = start_supervised({LocationsMock, name: locations_name, pid: self()}) - - opts = - Keyword.put_new_lazy(opts, :car, fn -> - settings = - Keyword.get(opts, :settings, %{}) - |> Map.put_new(:req_no_shift_state_reading, false) - |> Map.put_new(:req_no_temp_reading, false) - |> Map.put_new(:req_not_unlocked, true) - - %Car{ - id: :rand.uniform(65536), - eid: 0, - vid: 1000, - vin: "1000", - model: "3", - settings: struct(CarSettings, settings) - } - end) - - deps = - [ - name: name, - deps_log: {LogMock, log_name}, - deps_api: {ApiMock, api_name}, - deps_settings: {SettingsMock, settings_name}, - deps_locations: {LocationsMock, locations_name}, - deps_vehicles: {VehiclesMock, vehicles_name}, - deps_pubsub: {PubSubMock, pubsub_name} - ] - |> Enum.filter(fn - {:deps_log, _} -> mock_log? - _ -> true - end) - - {:ok, _pid} = start_supervised({Vehicle, Keyword.merge(opts, deps)}) - - assert_receive {SettingsMock, :subscribe_to_changes} - - :ok - end - - def online_event(opts \\ []) do - now = DateTime.utc_now() |> DateTime.to_unix(:millisecond) - - drive_state = - Keyword.get(opts, :drive_state, %{latitude: 0.0, longitude: 0.0}) - |> Map.update(:timestamp, now, fn - nil -> now - ts -> ts - end) - - charge_state = Keyword.get(opts, :charge_state, %{timestamp: 0}) - climate_state = Keyword.get(opts, :climate_state, %{timestamp: 0}) - vehicle_state = Keyword.get(opts, :vehicle_state, %{timestamp: 0, car_version: ""}) - vehicle_config = Keyword.get(opts, :vehicle_config, %{timestamp: 0, car_type: "model3"}) - - %TeslaApi.Vehicle{ - state: "online", - display_name: Keyword.get(opts, :display_name), - charge_state: struct(State.Charge, charge_state), - drive_state: struct(State.Drive, drive_state), - climate_state: struct(State.Climate, climate_state), - vehicle_state: struct(State.VehicleState, vehicle_state), - vehicle_config: struct(State.VehicleConfig, vehicle_config) - } - end - - def drive_event(ts, shift_state, speed_mph) do - online_event( - drive_state: %{ - timestamp: ts, - latitude: 0.1, - longitude: 0.1, - shift_state: shift_state, - speed: speed_mph - } - ) - end - - def charging_event(ts, charging_state, charge_energy_added, opts \\ []) do - range = Keyword.get(opts, :range) - - online_event( - charge_state: %{ - timestamp: ts, - charging_state: charging_state, - charge_energy_added: charge_energy_added, - ideal_battery_range: range, - battery_range: range - }, - drive_state: %{timestamp: ts, latitude: 0.0, longitude: 0.0} - ) - end - - defp update_event(ts, state, car_version, opts \\ []) do - alias TeslaApi.Vehicle.State.VehicleState.SoftwareUpdate - - update_version = Keyword.get(opts, :update_version) - - online_event( - vehicle_state: %{ - timestamp: ts, - car_version: car_version, - software_update: %SoftwareUpdate{ - expected_duration_sec: 2700, - status: state, - version: update_version - } - }, - drive_state: %{timestamp: ts, latitude: 0.0, longitude: 0.0} - ) - end + import TeslaMate.VehicleCase end end + + setup tags do + pid = Ecto.Adapters.SQL.Sandbox.start_owner!(TeslaMate.Repo, shared: not tags[:async]) + on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end) + :ok + rescue + e in [MatchError] -> + case e.term do + {:error, {{:badmatch, :already_shared}, _}} -> :ok + _ -> reraise e, __STACKTRACE__ + end + end + + alias TeslaMate.Vehicles.Vehicle + alias TeslaMate.Settings.CarSettings + alias TeslaMate.Log.{Car, Update} + alias TeslaApi.Vehicle.State + + def start_vehicle(name, events, opts \\ []) when length(events) > 0 do + mock_log? = Keyword.get(opts, :log, true) + last = Keyword.get(opts, :last_update, %Update{version: "9999.99.99.0 lasjas234"}) + + log_name = :"log_#{name}" + api_name = :"api_#{name}" + settings_name = :"settings_#{name}" + locations_name = :"locations_#{name}" + vehicles_name = :"vehicles_#{name}" + pubsub_name = :"pubsub_#{name}" + + {:ok, _pid} = start_supervised({LogMock, name: log_name, pid: self(), last_update: last}) + {:ok, _pid} = start_supervised({ApiMock, name: api_name, events: events, pid: self()}) + {:ok, _pid} = start_supervised({SettingsMock, name: settings_name, pid: self()}) + {:ok, _pid} = start_supervised({VehiclesMock, name: vehicles_name, pid: self()}) + {:ok, _pid} = start_supervised({PubSubMock, name: pubsub_name, pid: self()}) + {:ok, _pid} = start_supervised({LocationsMock, name: locations_name, pid: self()}) + + opts = + Keyword.put_new_lazy(opts, :car, fn -> + settings = + Keyword.get(opts, :settings, %{}) + |> Map.put_new(:req_no_shift_state_reading, false) + |> Map.put_new(:req_no_temp_reading, false) + |> Map.put_new(:req_not_unlocked, true) + + %Car{ + id: :rand.uniform(65536), + eid: 0, + vid: 1000, + vin: "1000", + model: "3", + settings: struct(CarSettings, settings) + } + end) + + deps = + [ + name: name, + deps_log: {LogMock, log_name}, + deps_api: {ApiMock, api_name}, + deps_settings: {SettingsMock, settings_name}, + deps_locations: {LocationsMock, locations_name}, + deps_vehicles: {VehiclesMock, vehicles_name}, + deps_pubsub: {PubSubMock, pubsub_name} + ] + |> Enum.filter(fn + {:deps_log, _} -> mock_log? + _ -> true + end) + + {:ok, _pid} = start_supervised({Vehicle, Keyword.merge(opts, deps)}) + + assert_receive {SettingsMock, :subscribe_to_changes} + + :ok + end + + def online_event(opts \\ []) do + now = DateTime.utc_now() |> DateTime.to_unix(:millisecond) + + drive_state = + Keyword.get(opts, :drive_state, %{latitude: 0.0, longitude: 0.0}) + |> Map.update(:timestamp, now, fn + nil -> now + ts -> ts + end) + + charge_state = Keyword.get(opts, :charge_state, %{timestamp: 0}) + climate_state = Keyword.get(opts, :climate_state, %{timestamp: 0}) + vehicle_state = Keyword.get(opts, :vehicle_state, %{timestamp: 0, car_version: ""}) + vehicle_config = Keyword.get(opts, :vehicle_config, %{timestamp: 0, car_type: "model3"}) + + %TeslaApi.Vehicle{ + state: "online", + display_name: Keyword.get(opts, :display_name), + charge_state: struct(State.Charge, charge_state), + drive_state: struct(State.Drive, drive_state), + climate_state: struct(State.Climate, climate_state), + vehicle_state: struct(State.VehicleState, vehicle_state), + vehicle_config: struct(State.VehicleConfig, vehicle_config) + } + end + + def drive_event(ts, shift_state, speed_mph) do + online_event( + drive_state: %{ + timestamp: ts, + latitude: 0.1, + longitude: 0.1, + shift_state: shift_state, + speed: speed_mph + } + ) + end + + def charging_event(ts, charging_state, charge_energy_added, opts \\ []) do + range = Keyword.get(opts, :range) + + online_event( + charge_state: %{ + timestamp: ts, + charging_state: charging_state, + charge_energy_added: charge_energy_added, + ideal_battery_range: range, + battery_range: range + }, + drive_state: %{timestamp: ts, latitude: 0.0, longitude: 0.0} + ) + end + + def update_event(ts, state, car_version, opts \\ []) do + alias TeslaApi.Vehicle.State.VehicleState.SoftwareUpdate + + update_version = Keyword.get(opts, :update_version) + + online_event( + vehicle_state: %{ + timestamp: ts, + car_version: car_version, + software_update: %SoftwareUpdate{ + expected_duration_sec: 2700, + status: state, + version: update_version + } + }, + drive_state: %{timestamp: ts, latitude: 0.0, longitude: 0.0} + ) + end end diff --git a/test/teslamate/import_test.exs b/test/teslamate/import_test.exs index 0048bfef..f4e2525b 100644 --- a/test/teslamate/import_test.exs +++ b/test/teslamate/import_test.exs @@ -481,30 +481,35 @@ defmodule TeslaMate.ImportTest do assert :ok = Import.run("Europe/Berlin") assert_receive %Status{ - files: [%{complete: false}, %{complete: false}, %{complete: false}], - state: :running - } + files: [%{complete: false}, %{complete: false}, %{complete: false}], + state: :running + }, + 1000 assert_receive %Status{ - files: [%{complete: false}, %{complete: false}, %{complete: false}], - state: :running - } + files: [%{complete: false}, %{complete: false}, %{complete: false}], + state: :running + }, + 1000 assert_receive %Status{ - files: [%{complete: true}, %{complete: false}, %{complete: false}], - state: :running - } + files: [%{complete: true}, %{complete: false}, %{complete: false}], + state: :running + }, + 1000 assert_receive %Status{ - files: [%{complete: true}, %{complete: true}, %{complete: false}], - state: :running - } + files: [%{complete: true}, %{complete: true}, %{complete: false}], + state: :running + }, + 1000 assert_receive %Status{ - files: [%{complete: true}, %{complete: true}, %{complete: false}], - state: :error, - message: msg - } + files: [%{complete: true}, %{complete: true}, %{complete: false}], + state: :error, + message: msg + }, + 1000 assert {{:badmatch, {:error, diff --git a/test/teslamate/vehicles/identification_test.exs b/test/teslamate/vehicles/identification_test.exs index a7bf648b..36c12c0d 100644 --- a/test/teslamate/vehicles/identification_test.exs +++ b/test/teslamate/vehicles/identification_test.exs @@ -1,6 +1,5 @@ defmodule TeslaMate.Vehicles.Vehicle.IdentificationTest do use TeslaMate.VehicleCase, async: false - use TeslaMateWeb.ConnCase alias TeslaMate.Log.Car alias TeslaMate.Log diff --git a/test/teslamate/vehicles/vehicle/charging_sync_test.exs b/test/teslamate/vehicles/vehicle/charging_sync_test.exs index 318b8f31..b2543834 100644 --- a/test/teslamate/vehicles/vehicle/charging_sync_test.exs +++ b/test/teslamate/vehicles/vehicle/charging_sync_test.exs @@ -1,9 +1,9 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingSyncTest do - use TeslaMate.DataCase - use TeslaMate.VehicleCase + use TeslaMate.VehicleCase, async: false import ExUnit.CaptureLog + alias TeslaMate.Vehicles.Vehicle.Summary alias TeslaMate.Log @log_opts format: "[$level] $message\n", diff --git a/test/teslamate/vehicles/vehicle/charging_test.exs b/test/teslamate/vehicles/vehicle/charging_test.exs index 6cfd131a..9e321299 100644 --- a/test/teslamate/vehicles/vehicle/charging_test.exs +++ b/test/teslamate/vehicles/vehicle/charging_test.exs @@ -1,6 +1,7 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do use TeslaMate.VehicleCase, async: true + alias TeslaMate.Vehicles.Vehicle.Summary alias TeslaMate.Log.ChargingProcess import ExUnit.CaptureLog diff --git a/test/teslamate/vehicles/vehicle/driving_test.exs b/test/teslamate/vehicles/vehicle/driving_test.exs index 4e980dc1..11ac512e 100644 --- a/test/teslamate/vehicles/vehicle/driving_test.exs +++ b/test/teslamate/vehicles/vehicle/driving_test.exs @@ -1,7 +1,8 @@ defmodule TeslaMate.Vehicles.Vehicle.DrivingTest do use TeslaMate.VehicleCase, async: true - alias TeslaMate.Log.{Drive, Car} + alias TeslaMate.Vehicles.Vehicle.Summary + alias TeslaMate.Log.Drive test "logs a full drive", %{test: name} do now = DateTime.utc_now() diff --git a/test/teslamate/vehicles/vehicle/streaming_test.exs b/test/teslamate/vehicles/vehicle/streaming_test.exs index 2d2a0539..8f2b826d 100644 --- a/test/teslamate/vehicles/vehicle/streaming_test.exs +++ b/test/teslamate/vehicles/vehicle/streaming_test.exs @@ -1,10 +1,10 @@ defmodule TeslaMate.Vehicles.Vehicle.StreamingTest do use TeslaMate.VehicleCase, async: true - use TeslaMate.DataCase, async: true import ExUnit.CaptureLog - alias TeslaMate.Log.Car + alias TeslaMate.Vehicles.Vehicle.Summary + alias TeslaMate.Vehicles.Vehicle alias TeslaApi.Stream defp stream(name, data) do diff --git a/test/teslamate/vehicles/vehicle/suspend_logging_test.exs b/test/teslamate/vehicles/vehicle/suspend_logging_test.exs index 3921d5ef..cfe13b0e 100644 --- a/test/teslamate/vehicles/vehicle/suspend_logging_test.exs +++ b/test/teslamate/vehicles/vehicle/suspend_logging_test.exs @@ -1,8 +1,7 @@ defmodule TeslaMate.Vehicles.Vehicle.SuspendLoggingTest do use TeslaMate.VehicleCase, async: true - alias TeslaMate.Vehicles.Vehicle - + alias TeslaMate.Vehicles.Vehicle.Summary alias TeslaMate.Vehicles.Vehicle test "immediately returns :ok if asleep", %{test: name} do diff --git a/test/teslamate/vehicles/vehicle/suspend_test.exs b/test/teslamate/vehicles/vehicle/suspend_test.exs index 83c16d88..2b676713 100644 --- a/test/teslamate/vehicles/vehicle/suspend_test.exs +++ b/test/teslamate/vehicles/vehicle/suspend_test.exs @@ -1,7 +1,7 @@ defmodule TeslaMate.Vehicles.Vehicle.SuspendTest do use TeslaMate.VehicleCase, async: true - alias TeslaMate.Vehicles.Vehicle + alias TeslaMate.Vehicles.Vehicle.Summary test "suspends when idling", %{test: name} do now_ts = DateTime.utc_now() |> DateTime.to_unix(:millisecond) diff --git a/test/teslamate/vehicles/vehicle/updating_test.exs b/test/teslamate/vehicles/vehicle/updating_test.exs index f74474fa..1351ed02 100644 --- a/test/teslamate/vehicles/vehicle/updating_test.exs +++ b/test/teslamate/vehicles/vehicle/updating_test.exs @@ -1,6 +1,8 @@ defmodule TeslaMate.Vehicles.Vehicle.UpdatingTest do use TeslaMate.VehicleCase, async: true + alias TeslaMate.Vehicles.Vehicle.Summary + @tag :capture_log test "logs an update cycle", %{test: name} do now = DateTime.utc_now() diff --git a/test/teslamate/vehicles/vehicle_sync_test.exs b/test/teslamate/vehicles/vehicle_sync_test.exs index 85d4b861..dd271386 100644 --- a/test/teslamate/vehicles/vehicle_sync_test.exs +++ b/test/teslamate/vehicles/vehicle_sync_test.exs @@ -1,8 +1,8 @@ defmodule TeslaMate.Vehicles.VehicleSyncTest do - use TeslaMate.DataCase - use TeslaMate.VehicleCase + use TeslaMate.VehicleCase, async: false describe "Summary" do + alias TeslaMate.Vehicles.Vehicle.Summary alias TeslaMate.Mqtt.PubSub.VehicleSubscriber alias TeslaMate.Log.Car alias TeslaMate.Log diff --git a/test/teslamate/vehicles/vehicle_test.exs b/test/teslamate/vehicles/vehicle_test.exs index 848144c2..2fcd2482 100644 --- a/test/teslamate/vehicles/vehicle_test.exs +++ b/test/teslamate/vehicles/vehicle_test.exs @@ -1,6 +1,10 @@ defmodule TeslaMate.Vehicles.VehicleTest do use TeslaMate.VehicleCase, async: true + alias TeslaMate.Vehicles.Vehicle.Summary + alias TeslaMate.Vehicles.Vehicle + alias TeslaMate.Log.{Car, Update} + describe "starting" do @tag :capture_log test "handles unknown and faulty states", %{test: name} do @@ -340,7 +344,7 @@ defmodule TeslaMate.Vehicles.VehicleTest do fuse_name = TestHelper.eventually( fn -> - assert %Vehicle.Summary{state: :asleep, healthy: true, car: %Car{id: id}} = + assert %Summary{state: :asleep, healthy: true, car: %Car{id: id}} = Vehicle.summary(name) :"#{Vehicle}_#{id}_api_error" @@ -373,7 +377,7 @@ defmodule TeslaMate.Vehicles.VehicleTest do :ok = start_vehicle(name, events) for _ <- 1..10 do - assert %Vehicle.Summary{state: :unavailable, healthy: true} = Vehicle.summary(name) + assert %Summary{state: :unavailable, healthy: true} = Vehicle.summary(name) end end @@ -393,7 +397,7 @@ defmodule TeslaMate.Vehicles.VehicleTest do assert_receive {ApiMock, {:stream, 1000, _}} for _ <- 1..10 do - assert %Vehicle.Summary{state: :online, healthy: true} = Vehicle.summary(name) + assert %Summary{state: :online, healthy: true} = Vehicle.summary(name) end end end diff --git a/test/teslamate/vehicles_test.exs b/test/teslamate/vehicles_test.exs index f1ad07c4..5224c429 100644 --- a/test/teslamate/vehicles_test.exs +++ b/test/teslamate/vehicles_test.exs @@ -2,6 +2,7 @@ defmodule TeslaMate.VehiclesTest do use TeslaMate.VehicleCase use TeslaMate.DataCase + alias TeslaMate.Vehicles.Vehicle alias TeslaMate.Vehicles @tag :capture_log @@ -68,7 +69,7 @@ defmodule TeslaMate.VehiclesTest do {:ok, _pid} = start_supervised({Vehicles, vehicle: VehicleMock}) - assert true = Vehicles.Vehicle.healthy?(id) + assert true = Vehicle.healthy?(id) end end @@ -87,12 +88,13 @@ defmodule TeslaMate.VehiclesTest do start_supervised!({Vehicles, vehicle: VehicleMock}) - assert true = Vehicles.Vehicle.healthy?(id) + assert true = Vehicle.healthy?(id) end end end describe "car settings" do + alias TeslaMate.Settings.CarSettings alias TeslaApi.Vehicle.State.VehicleConfig alias TeslaMate.{Log, Repo} alias TeslaMate.Vehicles.Vehicle.Summary diff --git a/test/teslamate_web/live/car_index_live_test.exs b/test/teslamate_web/live/car_index_live_test.exs index bf05271a..6a181194 100644 --- a/test/teslamate_web/live/car_index_live_test.exs +++ b/test/teslamate_web/live/car_index_live_test.exs @@ -2,7 +2,6 @@ defmodule TeslaMateWeb.CarLive.Indextest do use TeslaMateWeb.ConnCase use TeslaMate.VehicleCase - alias TeslaApi.Vehicle.State.VehicleState.SoftwareUpdate alias TeslaMate.Settings.GlobalSettings alias TeslaMate.Settings diff --git a/test/teslamate_web/live/charge_cost_live_test.exs b/test/teslamate_web/live/charge_cost_live_test.exs index 5948dffd..8bcd54b7 100644 --- a/test/teslamate_web/live/charge_cost_live_test.exs +++ b/test/teslamate_web/live/charge_cost_live_test.exs @@ -1,9 +1,8 @@ defmodule TeslaMateWeb.ChargeLive.CostTest do - use TeslaMateWeb.ConnCase - use TeslaMate.VehicleCase + use TeslaMateWeb.ConnCase, async: false + use TeslaMate.VehicleCase, async: false alias TeslaMate.Log.ChargingProcess - alias TeslaMate.Log.Car alias TeslaMate.{Log, Locations, Repo} import TestHelper, only: [decimal: 1]