diff options
author | lain <lain@soykaf.club> | 2024-06-01 11:30:42 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2024-06-01 11:30:42 +0000 |
commit | acde8d0e0c5ca954b71ec9425f9a0904113938c9 (patch) | |
tree | f895b4ebe622a30c6f6308e70a2272772d4d0b2c /test | |
parent | cdeeb4dcc5f6d91a96a7a5f407debcdcccc5087d (diff) | |
parent | cfc8d7aade526b8f119683984977064cd3cd3d87 (diff) | |
download | pleroma-acde8d0e0c5ca954b71ec9425f9a0904113938c9.tar.gz pleroma-acde8d0e0c5ca954b71ec9425f9a0904113938c9.zip |
Merge branch 'ipfs-dialyzer-fixes' into 'develop'
IPFS uploader: dialyzer fixes
See merge request pleroma/pleroma!4129
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/uploaders/ipfs_test.exs | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/test/pleroma/uploaders/ipfs_test.exs b/test/pleroma/uploaders/ipfs_test.exs index cf325b54f..bdf2933ac 100644 --- a/test/pleroma/uploaders/ipfs_test.exs +++ b/test/pleroma/uploaders/ipfs_test.exs @@ -14,25 +14,6 @@ defmodule Pleroma.Uploaders.IPFSTest do alias Pleroma.UnstubbedConfigMock, as: Config - describe "get_final_url" do - setup do - Config - |> expect(:get, fn [Pleroma.Uploaders.IPFS] -> - [post_gateway_url: "http://localhost:5001"] - end) - - :ok - end - - test "it returns the final url for put_file" do - assert IPFS.put_file_endpoint() == "http://localhost:5001/api/v0/add" - end - - test "it returns the final url for delete_file" do - assert IPFS.delete_file_endpoint() == "http://localhost:5001/api/v0/files/rm" - end - end - describe "get_file/1" do setup do Config @@ -71,8 +52,8 @@ defmodule Pleroma.Uploaders.IPFSTest do describe "put_file/1" do setup do Config - |> expect(:get, fn [Pleroma.Uploaders.IPFS] -> - [post_gateway_url: "http://localhost:5001"] + |> expect(:get, fn [Pleroma.Uploaders.IPFS, :post_gateway_url] -> + "http://localhost:5001" end) file_upload = %Pleroma.Upload{ @@ -92,7 +73,11 @@ defmodule Pleroma.Uploaders.IPFSTest do test "save file", %{file_upload: file_upload} do with_mock Pleroma.HTTP, - post: fn "http://localhost:5001/api/v0/add", _mp, [], params: ["cid-version": "1"] -> + post: fn "http://localhost:5001/api/v0/add", + _mp, + [], + params: ["cid-version": "1"], + pool: :upload -> {:ok, %Tesla.Env{ status: 200, @@ -107,7 +92,11 @@ defmodule Pleroma.Uploaders.IPFSTest do test "returns error", %{file_upload: file_upload} do with_mock Pleroma.HTTP, - post: fn "http://localhost:5001/api/v0/add", _mp, [], params: ["cid-version": "1"] -> + post: fn "http://localhost:5001/api/v0/add", + _mp, + [], + params: ["cid-version": "1"], + pool: :upload -> {:error, "IPFS Gateway upload failed"} end do assert capture_log(fn -> @@ -118,7 +107,11 @@ defmodule Pleroma.Uploaders.IPFSTest do test "returns error if JSON decode fails", %{file_upload: file_upload} do with_mock Pleroma.HTTP, [], - post: fn "http://localhost:5001/api/v0/add", _mp, [], params: ["cid-version": "1"] -> + post: fn "http://localhost:5001/api/v0/add", + _mp, + [], + params: ["cid-version": "1"], + pool: :upload -> {:ok, %Tesla.Env{status: 200, body: "invalid"}} end do assert capture_log(fn -> @@ -130,7 +123,11 @@ defmodule Pleroma.Uploaders.IPFSTest do test "returns error if JSON body doesn't contain Hash key", %{file_upload: file_upload} do with_mock Pleroma.HTTP, [], - post: fn "http://localhost:5001/api/v0/add", _mp, [], params: ["cid-version": "1"] -> + post: fn "http://localhost:5001/api/v0/add", + _mp, + [], + params: ["cid-version": "1"], + pool: :upload -> {:ok, %Tesla.Env{status: 200, body: "{\"key\": \"value\"}"}} end do assert IPFS.put_file(file_upload) == {:error, "JSON doesn't contain Hash key"} @@ -141,8 +138,8 @@ defmodule Pleroma.Uploaders.IPFSTest do describe "delete_file/1" do setup do Config - |> expect(:get, fn [Pleroma.Uploaders.IPFS] -> - [post_gateway_url: "http://localhost:5001"] + |> expect(:get, fn [Pleroma.Uploaders.IPFS, :post_gateway_url] -> + "http://localhost:5001" end) :ok |