Skip to content

Commit

Permalink
add a file read test
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek committed Oct 28, 2024
1 parent 5f8bf23 commit 6dcd0c7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/mindwendel_web/controllers/file_controller_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule MindwendelWeb.FileControllerTest do
use MindwendelWeb.ConnCase
alias Mindwendel.Services.Vault
alias Mindwendel.Factory

@file_dest Path.join("priv/static/uploads", "encrypted-test.jpg")

describe "get_file" do
setup do
{:ok, encrypted_file} = Vault.encrypt("test")
File.write(@file_dest, encrypted_file)

on_exit(fn -> File.rm(@file_dest) end)
:ok
end

test "successfully retrieves an existing file", %{conn: conn} do
file = Factory.insert!(:file, path: "/uploads/encrypted-test.jpg", name: "test.jpg")

assert get(conn, ~p"/files/#{file.id}").resp_body == "test"
end
end
end

0 comments on commit 6dcd0c7

Please sign in to comment.