Skip to content

Commit

Permalink
Use tmp dir in WIP file watcher test
Browse files Browse the repository at this point in the history
  • Loading branch information
gilest committed Dec 12, 2024
1 parent 8bb2b28 commit 8b375b3
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions test/watcher_test.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
defmodule WatcherTest do
use ExUnit.Case, async: true

alias PhoenixImportmap.Util

@moduletag :tmp_dir

@example_importmap %{
app: "/test/fixtures/js/app.js",
remote: "https://cdn.es6/package.js"
}

test "file watch" do
{:ok, _pid} = PhoenixImportmap.watch(@example_importmap, ~w(/test/fixtures))
setup %{tmp_dir: tmp_dir} do
relative_tmp_dir = Util.relative_path(tmp_dir)

Application.put_env(
:phoenix_importmap,
:copy_destination_path,
relative_tmp_dir <> "/assets"
)

Application.put_env(:phoenix_importmap, :public_asset_path_prefix, relative_tmp_dir)
File.mkdir_p!(tmp_dir <> "/assets")

{:ok, pid} =
start_supervised(
{PhoenixImportmap.Watcher,
%{
importmap: @example_importmap,
watch_dirs: ~w(/test/fixtures)
}}
)

%{pid: pid}
end

test "start supervised", %{pid: pid} do
assert pid
end
end

0 comments on commit 8b375b3

Please sign in to comment.