Skip to content

Commit

Permalink
Merge branch 'release/2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jul 3, 2024
2 parents d18ea0e + 592e0a0 commit db0e918
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/lexdee.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,10 @@ defmodule Lexdee do
defdelegate list_network_leases(client, id, options \\ []),
to: Networks.Leases,
as: :index

alias Lexdee.Images

defdelegate delete_image(client, fingerprint, options \\ []),
to: Images,
as: :remove
end
9 changes: 9 additions & 0 deletions lib/lexdee/images.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule Lexdee.Images do
use Tesla

@path "/1.0/images"

def remove(client, fingerprint, options \\ []) do
delete(client, Path.join(@path, fingerprint), options)
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Lexdee.MixProject do
def project do
[
app: :lexdee,
version: "2.3.11",
version: "2.4.0",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
39 changes: 39 additions & 0 deletions test/lexdee/images_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
defmodule Lexdee.ImagesTest do
use ExUnit.Case

setup do
bypass = Bypass.open()

client = Lexdee.create_client("http://localhost:#{bypass.port}")

{:ok, client: client, bypass: bypass}
end

describe "delete image" do
setup do
response =
File.read!("test/support/fixtures/responses/images/delete.json")

{:ok, response: response}
end

test "return success for deleting image", %{
bypass: bypass,
client: client,
response: response
} do
Bypass.expect(bypass, "DELETE", "/1.0/images/somefingerprint", fn conn ->
assert conn.query_string == "project=something"

conn
|> Plug.Conn.put_resp_header("content-type", "application/json")
|> Plug.Conn.resp(200, response)
end)

assert {:ok, _data} =
Lexdee.delete_image(client, "somefingerprint",
query: [project: "something"]
)
end
end
end
26 changes: 26 additions & 0 deletions test/support/fixtures/responses/images/delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"type": "async",
"status": "Operation created",
"status_code": 100,
"operation": "/1.0/operations/cacccf96-c1c1-44c3-bc4a-2790689ee9e8",
"error_code": 0,
"error": "",
"metadata": {
"id": "cacccf96-c1c1-44c3-bc4a-2790689ee9e8",
"class": "task",
"description": "Deleting image",
"created_at": "2024-07-03T03:36:31.263738129Z",
"updated_at": "2024-07-03T03:36:31.263738129Z",
"status": "Running",
"status_code": 103,
"resources": {
"images": [
"/1.0/images/fcfbb271b12ecb50b5a686fcc74ad1920d254b3127ce0f76172014c3370457d1?project=icepak-test"
]
},
"metadata": null,
"may_cancel": false,
"err": "",
"location": "none"
}
}

0 comments on commit db0e918

Please sign in to comment.