diff --git a/test/nerves_hub/devices_test.exs b/test/nerves_hub/devices_test.exs index 16d0be8a7..d24499c40 100644 --- a/test/nerves_hub/devices_test.exs +++ b/test/nerves_hub/devices_test.exs @@ -376,378 +376,379 @@ defmodule NervesHub.DevicesTest do test "get_device_by_identifier without existing device", %{org: org} do assert {:error, :not_found} = Devices.get_device_by_identifier(org, "non existing identifier") end -end - -test "deployments limit deploying by product", %{ - user: user, - org: org, - org_key: org_key, - firmware: firmware, - product: product -} do - old_deployment_group = - Fixtures.deployment_group_fixture(org, firmware, %{ - name: "a different name", - conditions: %{"tags" => ["beta", "beta-edge"], "version" => ""} - }) - firmware1 = Fixtures.firmware_fixture(org_key, product, %{version: "2.0.0"}) + test "deployments limit deploying by product", %{ + user: user, + org: org, + org_key: org_key, + firmware: firmware, + product: product + } do + old_deployment_group = + Fixtures.deployment_group_fixture(org, firmware, %{ + name: "a different name", + conditions: %{"tags" => ["beta", "beta-edge"], "version" => ""} + }) - ManagedDeployments.update_deployment_group(old_deployment_group, %{ - firmware_id: firmware1.id, - is_active: true - }) + firmware1 = Fixtures.firmware_fixture(org_key, product, %{version: "2.0.0"}) - device = - Fixtures.device_fixture(org, product, firmware, %{ - identifier: "new identifier", - tags: ["beta", "beta-edge"] + ManagedDeployments.update_deployment_group(old_deployment_group, %{ + firmware_id: firmware1.id, + is_active: true }) - product2 = Fixtures.product_fixture(user, org, %{name: "other product"}) - firmware2 = Fixtures.firmware_fixture(org_key, product2) + device = + Fixtures.device_fixture(org, product, firmware, %{ + identifier: "new identifier", + tags: ["beta", "beta-edge"] + }) - params = %{ - org_id: org.id, - firmware_id: firmware2.id, - name: "my deployment", - conditions: %{ - "version" => "", - "tags" => ["beta", "beta-edge"] - }, - is_active: false - } + product2 = Fixtures.product_fixture(user, org, %{name: "other product"}) + firmware2 = Fixtures.firmware_fixture(org_key, product2) - {:ok, _deployment_group2} = - ManagedDeployments.create_deployment_group(params) - |> elem(1) - |> ManagedDeployments.update_deployment_group(%{is_active: true}) + params = %{ + org_id: org.id, + firmware_id: firmware2.id, + name: "my deployment", + conditions: %{ + "version" => "", + "tags" => ["beta", "beta-edge"] + }, + is_active: false + } - {:ok, device} = Devices.get_device_by_org(org, device.id) + {:ok, _deployment_group2} = + ManagedDeployments.create_deployment_group(params) + |> elem(1) + |> ManagedDeployments.update_deployment_group(%{is_active: true}) - deployment_groups = - ManagedDeployments.eligible_deployment_groups(device) - |> NervesHub.Repo.preload(:firmware) + {:ok, device} = Devices.get_device_by_org(org, device.id) - assert length(deployment_groups) == 1 + deployment_groups = + ManagedDeployments.eligible_deployment_groups(device) + |> NervesHub.Repo.preload(:firmware) - for deployment_group <- deployment_group_groups do - assert deployment_group.firmware.product_id == product.id + assert length(deployment_groups) == 1 + + for deployment_group <- deployment_groups do + assert deployment_group.firmware.product_id == product.id + end end -end -test "delta_updatable?", %{ - firmware: source, - product: product, - deployment_group: deployment_group -} do - fwup_version = @valid_fwup_version - %{firmware: target} = Repo.preload(deployment_group, :firmware) + test "delta_updatable?", %{ + firmware: source, + product: product, + deployment_group: deployment_group + } do + fwup_version = @valid_fwup_version + %{firmware: target} = Repo.preload(deployment_group, :firmware) - assert Devices.delta_updatable?(source, target, product, fwup_version) == false + assert Devices.delta_updatable?(source, target, product, fwup_version) == false - source = Ecto.Changeset.change(source, delta_updatable: true) |> Repo.update!() - target = Ecto.Changeset.change(target, delta_updatable: true) |> Repo.update!() + source = Ecto.Changeset.change(source, delta_updatable: true) |> Repo.update!() + target = Ecto.Changeset.change(target, delta_updatable: true) |> Repo.update!() - assert product.delta_updatable == true - assert source.delta_updatable == true - assert target.delta_updatable == true + assert product.delta_updatable == true + assert source.delta_updatable == true + assert target.delta_updatable == true - assert Devices.delta_updatable?(source, target, product, fwup_version) == true + assert Devices.delta_updatable?(source, target, product, fwup_version) == true - # case where the source firmware does not exist - assert Devices.delta_updatable?(nil, target, product, fwup_version) == false -end + # case where the source firmware does not exist + assert Devices.delta_updatable?(nil, target, product, fwup_version) == false + end -test "matches_deployment_group? works when device and/or deployment tags are nil", %{ - deployment_group: deployment_group, - device: device -} do - # There is a version check before the tags, so load both versions - # here to ensure they match and we get to the tag check - device = put_in(device.firmware_metadata.version, "1.0.0") - deployment_group = put_in(deployment_group.conditions["version"], "1.0.0") + test "matches_deployment_group? works when device and/or deployment tags are nil", %{ + deployment_group: deployment_group, + device: device + } do + # There is a version check before the tags, so load both versions + # here to ensure they match and we get to the tag check + device = put_in(device.firmware_metadata.version, "1.0.0") + deployment_group = put_in(deployment_group.conditions["version"], "1.0.0") - nil_tags_deployment_group = put_in(deployment_group.conditions["tags"], nil) + nil_tags_deployment_group = put_in(deployment_group.conditions["tags"], nil) - refute Devices.matches_deployment_group?(%{device | tags: nil}, deployment_group) - assert Devices.matches_deployment_group?(%{device | tags: nil}, nil_tags_deployment_group) - assert Devices.matches_deployment_group?(device, nil_tags_deployment_group) -end + refute Devices.matches_deployment_group?(%{device | tags: nil}, deployment_group) + assert Devices.matches_deployment_group?(%{device | tags: nil}, nil_tags_deployment_group) + assert Devices.matches_deployment_group?(device, nil_tags_deployment_group) + end -test "create shared secret auth with associated product shared secret auth", context do - {:ok, %{id: product_ssa_id}} = Products.create_shared_secret_auth(context.product) + test "create shared secret auth with associated product shared secret auth", context do + {:ok, %{id: product_ssa_id}} = Products.create_shared_secret_auth(context.product) - assert {:ok, auth} = - Devices.create_shared_secret_auth(context.device, %{ - product_shared_secret_auth_id: product_ssa_id - }) + assert {:ok, auth} = + Devices.create_shared_secret_auth(context.device, %{ + product_shared_secret_auth_id: product_ssa_id + }) - assert auth.product_shared_secret_auth_id == product_ssa_id -end + assert auth.product_shared_secret_auth_id == product_ssa_id + end -describe "tracking update attempts and verifying eligibility" do - test "records the timestamp of an attempt", %{device: device} do - {:ok, device} = Devices.update_attempted(device) - assert Enum.count(device.update_attempts) == 1 + describe "tracking update attempts and verifying eligibility" do + test "records the timestamp of an attempt", %{device: device} do + {:ok, device} = Devices.update_attempted(device) + assert Enum.count(device.update_attempts) == 1 - {:ok, device} = Devices.update_attempted(device) - assert Enum.count(device.update_attempts) == 2 - end + {:ok, device} = Devices.update_attempted(device) + assert Enum.count(device.update_attempts) == 2 + end - test "records and audit log for updating", %{device: device} do - assert [] = AuditLogs.logs_for(device) + test "records and audit log for updating", %{device: device} do + assert [] = AuditLogs.logs_for(device) - {:ok, device} = Devices.update_attempted(device) + {:ok, device} = Devices.update_attempted(device) - [audit_log] = AuditLogs.logs_for(device) + [audit_log] = AuditLogs.logs_for(device) - assert audit_log.description =~ ~r/attempting to update/ - end + assert audit_log.description =~ ~r/attempting to update/ + end - test "resets update attempts on successful update", %{device: device} do - {:ok, device} = Devices.update_attempted(device) - assert Enum.count(device.update_attempts) == 1 + test "resets update attempts on successful update", %{device: device} do + {:ok, device} = Devices.update_attempted(device) + assert Enum.count(device.update_attempts) == 1 - {:ok, device} = Devices.firmware_update_successful(device) - assert Enum.empty?(device.update_attempts) - end + {:ok, device} = Devices.firmware_update_successful(device) + assert Enum.empty?(device.update_attempts) + end - test "clears an inflight update if it matches", %{ - device: device, - deployment_group: deployment_group - } do - deployment = Repo.preload(deployment_group, [:firmware]) - {:ok, inflight_update} = Devices.told_to_update(device, deployment_group) + test "clears an inflight update if it matches", %{ + device: device, + deployment_group: deployment_group + } do + deployment_group = Repo.preload(deployment_group, [:firmware]) + {:ok, inflight_update} = Devices.told_to_update(device, deployment_group) - {:ok, _device} = Devices.firmware_update_successful(device) + {:ok, _device} = Devices.firmware_update_successful(device) - inflight_update = Repo.reload(inflight_update) - assert is_nil(inflight_update) - end + inflight_update = Repo.reload(inflight_update) + assert is_nil(inflight_update) + end - test "increments the deployment's updated count", %{ - device: device, - deployment_group: deployment_group - } do - deployment_group = Repo.preload(deployment_group, [:firmware]) - assert deployment_group.current_updated_devices == 0 + test "increments the deployment's updated count", %{ + device: device, + deployment_group: deployment_group + } do + deployment_group = Repo.preload(deployment_group, [:firmware]) + assert deployment_group.current_updated_devices == 0 - {:ok, _inflight_update} = Devices.told_to_update(device, deployment_group) + {:ok, _inflight_update} = Devices.told_to_update(device, deployment_group) - {:ok, _device} = Devices.firmware_update_successful(device) + {:ok, _device} = Devices.firmware_update_successful(device) - deployment_group = Repo.reload(deployment_group) - assert deployment_group.current_updated_devices == 1 - end + deployment_group = Repo.reload(deployment_group) + assert deployment_group.current_updated_devices == 1 + end - test "device updates successfully", %{device: device, deployment_group: deployment_group} do - deployment_group = Repo.preload(deployment_group, [:firmware]) + test "device updates successfully", %{device: device, deployment_group: deployment_group} do + deployment_group = Repo.preload(deployment_group, [:firmware]) - {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) + {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) - {:ok, device} = Devices.update_attempted(device) + {:ok, device} = Devices.update_attempted(device) - {:ok, device} = Devices.verify_update_eligibility(device, deployment_group) + {:ok, device} = Devices.verify_update_eligibility(device, deployment_group) - assert device.updates_enabled - refute device.updates_blocked_until - end + assert device.updates_enabled + refute device.updates_blocked_until + end - test "device updates successfully after a few attempts", %{ - device: device, - deployment_group: deployment_group - } do - deployment_group = Repo.preload(deployment_group, [:firmware]) + test "device updates successfully after a few attempts", %{ + device: device, + deployment_group: deployment_group + } do + deployment_group = Repo.preload(deployment_group, [:firmware]) - {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) + {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) - {:ok, device} = Devices.update_attempted(device) - {:ok, device} = Devices.update_attempted(device) + {:ok, device} = Devices.update_attempted(device) + {:ok, device} = Devices.update_attempted(device) - {:ok, device} = Devices.verify_update_eligibility(device, deployment_group) + {:ok, device} = Devices.verify_update_eligibility(device, deployment_group) - assert device.updates_enabled - refute device.updates_blocked_until - end + assert device.updates_enabled + refute device.updates_blocked_until + end - test "device updates successfully after a few attempts over a long period of time", state do - %{device: device, deployment_group: deployment_group} = state + test "device updates successfully after a few attempts over a long period of time", state do + %{device: device, deployment_group: deployment_group} = state - deployment_group = %{ - deployment_group - | device_failure_threshold: 6, - device_failure_rate_amount: 3 - } + deployment_group = %{ + deployment_group + | device_failure_threshold: 6, + device_failure_rate_amount: 3 + } - deployment_group = Repo.preload(deployment_group, [:firmware]) + deployment_group = Repo.preload(deployment_group, [:firmware]) - {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) + {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) - now = DateTime.utc_now() + now = DateTime.utc_now() - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -3600, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -1200, :second)) - {:ok, device} = Devices.update_attempted(device, now) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -3600, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -1200, :second)) + {:ok, device} = Devices.update_attempted(device, now) - {:ok, device} = Devices.verify_update_eligibility(device, deployment_group) + {:ok, device} = Devices.verify_update_eligibility(device, deployment_group) - assert device.updates_enabled - refute device.updates_blocked_until - end + assert device.updates_enabled + refute device.updates_blocked_until + end - test "device already matches the firmware of the deployment", state do - %{device: device, deployment_group: deployment_group} = state - deployment = Repo.preload(deployment, [:firmware]) + test "device already matches the firmware of the deployment", state do + %{device: device, deployment_group: deployment_group} = state + deployment_group = Repo.preload(deployment_group, [:firmware]) - {:error, :up_to_date, _device} = Devices.verify_update_eligibility(device, deployment) - end + {:error, :up_to_date, _device} = Devices.verify_update_eligibility(device, deployment_group) + end - test "device should be rejected for updates based on threshold rate and have it's inflight updates cleared", - state do - %{device: device, deployment_group: deployment_group} = state - deployment_group = Repo.preload(deployment, [:firmware]) - deployment_group = %{deployment_group | device_failure_threshold: 6} + test "device should be rejected for updates based on threshold rate and have it's inflight updates cleared", + state do + %{device: device, deployment_group: deployment_group} = state + deployment_group = Repo.preload(deployment_group, [:firmware]) + deployment_group = %{deployment_group | device_failure_threshold: 6} - {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) - {:ok, _inflight_update} = Devices.told_to_update(device, deployment_group) + {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) + {:ok, _inflight_update} = Devices.told_to_update(device, deployment_group) - now = DateTime.utc_now() + now = DateTime.utc_now() - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -3600, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -1200, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -500, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -500, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -500, :second)) - {:ok, device} = Devices.update_attempted(device, now) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -3600, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -1200, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -500, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -500, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -500, :second)) + {:ok, device} = Devices.update_attempted(device, now) - {:error, :updates_blocked, device} = - Devices.verify_update_eligibility(device, deployment_group) + {:error, :updates_blocked, device} = + Devices.verify_update_eligibility(device, deployment_group) - assert device.updates_blocked_until - assert Devices.count_inflight_updates_for(deployment_group) == 0 - end + assert device.updates_blocked_until + assert Devices.count_inflight_updates_for(deployment_group) == 0 + end - test "device should be rejected for updates based on attempt rate and have it's inflight updates cleared", - state do - %{device: device, deployment_group: deployment_group} = state - deployment = Repo.preload(deployment, [:firmware]) + test "device should be rejected for updates based on attempt rate and have it's inflight updates cleared", + state do + %{device: device, deployment_group: deployment_group} = state + deployment_group = Repo.preload(deployment_group, [:firmware]) - {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) - {:ok, _inflight_update} = Devices.told_to_update(device, deployment) + {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) + {:ok, _inflight_update} = Devices.told_to_update(device, deployment_group) - now = DateTime.utc_now() + now = DateTime.utc_now() - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -13, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -10, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -5, :second)) - {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -2, :second)) - {:ok, device} = Devices.update_attempted(device, now) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -13, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -10, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -5, :second)) + {:ok, device} = Devices.update_attempted(device, DateTime.add(now, -2, :second)) + {:ok, device} = Devices.update_attempted(device, now) - {:error, :updates_blocked, device} = Devices.verify_update_eligibility(device, deployment) + {:error, :updates_blocked, device} = + Devices.verify_update_eligibility(device, deployment_group) - assert device.updates_blocked_until - assert Devices.count_inflight_updates_for(deployment) == 0 - end + assert device.updates_blocked_until + assert Devices.count_inflight_updates_for(deployment_group) == 0 + end - test "device in penalty box should be rejected for updates and have it's inflight updates cleared", - state do - %{device: device, deployment_group: deployment_group} = state - deployment = Repo.preload(deployment, [:firmware]) + test "device in penalty box should be rejected for updates and have it's inflight updates cleared", + state do + %{device: device, deployment_group: deployment_group} = state + deployment_group = Repo.preload(deployment_group, [:firmware]) - {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) + {:ok, device} = update_firmware_uuid(device, Ecto.UUID.generate()) - now = DateTime.utc_now() + now = DateTime.utc_now() - # future time - device = %{device | updates_blocked_until: DateTime.add(now, 1, :second)} - {:ok, _inflight_update} = Devices.told_to_update(device, deployment) + # future time + device = %{device | updates_blocked_until: DateTime.add(now, 1, :second)} + {:ok, _inflight_update} = Devices.told_to_update(device, deployment_group) - {:error, :updates_blocked, _device} = - Devices.verify_update_eligibility(device, deployment, now) + {:error, :updates_blocked, _device} = + Devices.verify_update_eligibility(device, deployment_group, now) - assert Devices.count_inflight_updates_for(deployment) == 0 + assert Devices.count_inflight_updates_for(deployment_group) == 0 - # now - device = %{device | updates_blocked_until: now} - {:ok, _device} = Devices.verify_update_eligibility(device, deployment, now) + # now + device = %{device | updates_blocked_until: now} + {:ok, _device} = Devices.verify_update_eligibility(device, deployment_group, now) - # past time - device = %{device | updates_blocked_until: DateTime.add(now, -1, :second)} - {:ok, _device} = Devices.verify_update_eligibility(device, deployment, now) + # past time + device = %{device | updates_blocked_until: DateTime.add(now, -1, :second)} + {:ok, _device} = Devices.verify_update_eligibility(device, deployment_group, now) + end end -end -describe "inflight updates" do - test "clears expired inflight updates", %{device: device, deployment_group: deployment_group} do - deployment = Repo.preload(deployment, :firmware) - Fixtures.inflight_update(device, deployment) - assert {0, _} = Devices.delete_expired_inflight_updates() + describe "inflight updates" do + test "clears expired inflight updates", %{device: device, deployment_group: deployment_group} do + deployment_group = Repo.preload(deployment_group, :firmware) + Fixtures.inflight_update(device, deployment_group) + assert {0, _} = Devices.delete_expired_inflight_updates() - Devices.clear_inflight_update(device) + Devices.clear_inflight_update(device) - expires_at = - DateTime.utc_now() - |> DateTime.shift(hour: -1) - |> DateTime.truncate(:second) + expires_at = + DateTime.utc_now() + |> DateTime.shift(hour: -1) + |> DateTime.truncate(:second) - Fixtures.inflight_update(device, deployment, %{"expires_at" => expires_at}) - assert {1, _} = Devices.delete_expired_inflight_updates() + Fixtures.inflight_update(device, deployment_group, %{"expires_at" => expires_at}) + assert {1, _} = Devices.delete_expired_inflight_updates() + end end -end -defp update_firmware_uuid(device, uuid) do - firmware_metadata = %{ - architecture: "x86_64", - platform: "platform", - product: "valid product", - version: "1.0.0", - uuid: uuid - } + defp update_firmware_uuid(device, uuid) do + firmware_metadata = %{ + architecture: "x86_64", + platform: "platform", + product: "valid product", + version: "1.0.0", + uuid: uuid + } - Devices.update_firmware_metadata(device, firmware_metadata) -end + Devices.update_firmware_metadata(device, firmware_metadata) + end -describe "device health reports" do - test "create new device health", %{device: device} do - device_health = %{"device_id" => device.id, "data" => %{"literally_any_map" => "values"}} + describe "device health reports" do + test "create new device health", %{device: device} do + device_health = %{"device_id" => device.id, "data" => %{"literally_any_map" => "values"}} - assert {:ok, %Devices.DeviceHealth{id: health_id}} = - Devices.save_device_health(device_health) + assert {:ok, %Devices.DeviceHealth{id: health_id}} = + Devices.save_device_health(device_health) - assert %Devices.DeviceHealth{} = Devices.get_latest_health(device.id) + assert %Devices.DeviceHealth{} = Devices.get_latest_health(device.id) - # Assert device is updated with latest health - assert %{latest_health_id: ^health_id} = Devices.get_device(device.id) + # Assert device is updated with latest health + assert %{latest_health_id: ^health_id} = Devices.get_device(device.id) + end end -end -describe "update_deployment_group/2" do - test "updates deployment and broadcasts 'devices/deployment-group-updated'", %{ - device: device, - deployment_group: deployment_group - } do - refute device.deployment_id + describe "update_deployment_group/2" do + test "updates deployment and broadcasts 'devices/deployment-group-updated'", %{ + device: device, + deployment_group: deployment_group + } do + refute device.deployment_id - NervesHubWeb.Endpoint.subscribe("device:#{device.id}") - device = Devices.update_deployment_group(device, deployment_group) + NervesHubWeb.Endpoint.subscribe("device:#{device.id}") + device = Devices.update_deployment_group(device, deployment_group) - assert device.deployment_id == deployment_group.id - assert_receive %{event: "devices/deployment-group-updated"} + assert device.deployment_id == deployment_group.id + assert_receive %{event: "devices/deployment-group-updated"} + end end -end -describe "clear_deployment_group/2" do - test "clears deployment and broadcasts 'devices/deployment-group-cleared'", %{ - device: device, - deployment_group: deployment_group - } do - device = Devices.update_deployment_group(device, deployment) + describe "clear_deployment_group/2" do + test "clears deployment and broadcasts 'devices/deployment-group-cleared'", %{ + device: device, + deployment_group: deployment_group + } do + device = Devices.update_deployment_group(device, deployment_group) - NervesHubWeb.Endpoint.subscribe("device:#{device.id}") - device = Devices.clear_deployment_group(device) + NervesHubWeb.Endpoint.subscribe("device:#{device.id}") + device = Devices.clear_deployment_group(device) - refute device.deployment_id - assert_receive %{event: "devices/deployment-group-cleared"} + refute device.deployment_id + assert_receive %{event: "devices/deployment-group-cleared"} + end end end diff --git a/test/nerves_hub_web/channels/websocket_test.exs b/test/nerves_hub_web/channels/websocket_test.exs index 2b28586fc..a296ce24e 100644 --- a/test/nerves_hub_web/channels/websocket_test.exs +++ b/test/nerves_hub_web/channels/websocket_test.exs @@ -796,7 +796,7 @@ defmodule NervesHubWeb.WebsocketTest do [log, _, _] = AuditLogs.logs_by(device) assert log.description == - "Device no longer matches deployment Every Device's requirements because of mismatched architecture and platform" + "Device no longer matches deployment group Every Device's requirements because of mismatched architecture and platform" close_socket_cleanly(socket) end diff --git a/test/nerves_hub_web/controllers/api/deployment_controller_test.exs b/test/nerves_hub_web/controllers/api/deployment_controller_test.exs index 8a2708869..8a9b7d6b8 100644 --- a/test/nerves_hub_web/controllers/api/deployment_controller_test.exs +++ b/test/nerves_hub_web/controllers/api/deployment_controller_test.exs @@ -100,7 +100,7 @@ defmodule NervesHubWeb.API.DeploymentGroupControllerTest do deployment_group.name ) - conn = put(conn, path, deployment_group: %{"is_active" => true}) + conn = put(conn, path, deployment: %{"is_active" => true}) assert %{"is_active" => true} = json_response(conn, 200)["data"] path = @@ -132,7 +132,7 @@ defmodule NervesHubWeb.API.DeploymentGroupControllerTest do ) refute deployment_group.is_active - conn = put(conn, path, deployment_group: %{"state" => "on"}) + conn = put(conn, path, deployment: %{"state" => "on"}) assert %{"is_active" => true, "state" => "on"} = json_response(conn, 200)["data"] path = @@ -164,7 +164,7 @@ defmodule NervesHubWeb.API.DeploymentGroupControllerTest do deployment_group.name ) - conn = put(conn, path, deployment_group: %{"is_active" => true}) + conn = put(conn, path, deployment: %{"is_active" => true}) assert json_response(conn, 200)["data"] [audit_log] = AuditLogs.logs_for(deployment_group) @@ -186,7 +186,7 @@ defmodule NervesHubWeb.API.DeploymentGroupControllerTest do deployment_group.name ) - conn = put(conn, path, deployment_group: %{is_active: "1234"}) + conn = put(conn, path, deployment: %{is_active: "1234"}) assert json_response(conn, 422)["errors"] != %{} end end