Skip to content

Commit

Permalink
Merge branch 'release/2.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jul 17, 2024
2 parents 1f0205f + e74d8db commit bc54358
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/lexdee.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ defmodule Lexdee do
to: Instances,
as: :create

defdelegate update_instance(client, id, params, opts \\ []),
to: Instances,
as: :update

defdelegate show_instance_log(client, instance, file_name, opts \\ []),
to: Instances.Logs,
as: :show
Expand Down
5 changes: 5 additions & 0 deletions lib/lexdee/instances.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ defmodule Lexdee.Instances do
def create(client, params, opts \\ []),
do: post(client, @path, params, opts)

@spec update(Tesla.Client.t(), binary(), map, Keyword.t()) ::
{:error, any} | {:ok, Tesla.Env.t()}
def update(client, id, params, options \\ []),
do: patch(client, Path.join(@path, id), params, options)

@spec remove(Tesla.Client.t(), binary(), Keyword.t()) ::
{:ok, Tesla.Env.t()} | {:error, any()}
def remove(client, id, options \\ []),
Expand Down
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.4.1",
version: "2.4.2",
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
38 changes: 38 additions & 0 deletions test/lexdee/instances_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,44 @@ defmodule Lexdee.InstancesTest do
end
end

describe "update instance" do
setup do
response =
File.read!("test/support/fixtures/responses/instances/update.json")

{:ok, response: response}
end

test "return success for updated instance", %{
bypass: bypass,
client: client,
response: response
} do
Bypass.expect(
bypass,
"PATCH",
"/1.0/instances/something",
fn conn ->
assert conn.query_string == "target=lxd-experiment"

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

assert {:ok, _data} =
Lexdee.update_instance(
client,
"something",
%{
"profiles" => ["some-profile"]
},
query: [target: "lxd-experiment"]
)
end
end

describe "delete instance" do
setup do
response =
Expand Down
5 changes: 5 additions & 0 deletions test/support/fixtures/responses/instances/update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"status": "Success",
"status_code": 200,
"type": "sync"
}

0 comments on commit bc54358

Please sign in to comment.