Skip to content

Commit

Permalink
Add ability to skip update instance if package size is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jul 17, 2024
1 parent 1cc57e9 commit 77718bb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/uplink/packages/instance/upgrade.ex
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ defmodule Uplink.Packages.Instance.Upgrade do
|> Oban.insert()
end

defp handle_update_config(client, _instance, %Metadata{package_size: nil}),
do: client

defp handle_update_config(client, instance, metadata) do
profile_name = Packages.profile_name(metadata)
size_profile_name = Packages.get_or_create_size_profile(client, metadata)
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/lxd/instances/update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"status": "Success",
"status_code": 200,
"type": "sync"
}
15 changes: 15 additions & 0 deletions test/uplink/packages/instance/upgrade_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ defmodule Uplink.Packages.Instance.UpgradeTest do
}

describe "upgrade instance with size profile" do
setup [:setup_base_with_package_size]

setup %{app: app, metadata: metadata} do
{:ok, first_deployment} =
Packages.get_or_create_deployment(app, @first_deployment)
Expand Down Expand Up @@ -871,6 +873,19 @@ defmodule Uplink.Packages.Instance.UpgradeTest do
end
)

update_instance = File.read!("test/fixtures/lxd/instances/update.json")

Bypass.expect_once(
bypass,
"PATCH",
"/1.0/instances/#{instance_slug}",
fn conn ->
conn
|> Plug.Conn.put_resp_header("content-type", "application/json")
|> Plug.Conn.resp(200, update_instance)
end
)

Bypass.expect_once(
bypass,
"POST",
Expand Down

0 comments on commit 77718bb

Please sign in to comment.