logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

ex_aws_test.exs (1421B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.HTTP.ExAwsTest do
  5. use ExUnit.Case
  6. import Tesla.Mock
  7. alias Pleroma.HTTP
  8. @url "https://s3.amazonaws.com/test_bucket/test_image.jpg"
  9. setup do
  10. mock(fn
  11. %{method: :get, url: @url, headers: [{"x-amz-bucket-region", "us-east-1"}]} ->
  12. %Tesla.Env{
  13. status: 200,
  14. body: "image-content",
  15. headers: [{"x-amz-bucket-region", "us-east-1"}]
  16. }
  17. %{method: :post, url: @url, body: "image-content-2"} ->
  18. %Tesla.Env{status: 200, body: "image-content-2"}
  19. end)
  20. :ok
  21. end
  22. describe "request" do
  23. test "get" do
  24. assert HTTP.ExAws.request(:get, @url, "", [{"x-amz-bucket-region", "us-east-1"}]) == {
  25. :ok,
  26. %{
  27. body: "image-content",
  28. headers: [{"x-amz-bucket-region", "us-east-1"}],
  29. status_code: 200
  30. }
  31. }
  32. end
  33. test "post" do
  34. assert HTTP.ExAws.request(:post, @url, "image-content-2", [
  35. {"x-amz-bucket-region", "us-east-1"}
  36. ]) == {
  37. :ok,
  38. %{
  39. body: "image-content-2",
  40. headers: [],
  41. status_code: 200
  42. }
  43. }
  44. end
  45. end
  46. end