@@ -2,9 +2,13 @@ defmodule Codex.Plugins.WriterTest do
22 use ExUnit.Case , async: true
33
44 alias Codex.Plugins
5+ alias Codex.TestSupport.TempDir
56
67 test "manifest writes are deterministic, pretty, and newline terminated" do
7- temp_root = temp_root ( "plugin_writer_manifest" )
8+ temp_root =
9+ TempDir . create! ( "plugin_writer_manifest" )
10+ |> tap ( & on_exit ( fn -> File . rm_rf! ( & 1 ) end ) )
11+
812 manifest_path = Path . join ( [ temp_root , "demo-plugin" , ".codex-plugin" , "plugin.json" ] )
913
1014 { :ok , manifest } =
@@ -27,7 +31,10 @@ defmodule Codex.Plugins.WriterTest do
2731 end
2832
2933 test "overwrite protection prevents silent clobbering" do
30- temp_root = temp_root ( "plugin_writer_overwrite" )
34+ temp_root =
35+ TempDir . create! ( "plugin_writer_overwrite" )
36+ |> tap ( & on_exit ( fn -> File . rm_rf! ( & 1 ) end ) )
37+
3138 manifest_path = Path . join ( [ temp_root , "demo-plugin" , ".codex-plugin" , "plugin.json" ] )
3239
3340 File . mkdir_p! ( Path . dirname ( manifest_path ) )
@@ -40,7 +47,10 @@ defmodule Codex.Plugins.WriterTest do
4047 end
4148
4249 test "marketplace updates merge new plugins without erasing unrelated entries" do
43- temp_root = temp_root ( "plugin_writer_marketplace" )
50+ temp_root =
51+ TempDir . create! ( "plugin_writer_marketplace" )
52+ |> tap ( & on_exit ( fn -> File . rm_rf! ( & 1 ) end ) )
53+
4454 repo_root = Path . join ( temp_root , "repo" )
4555 marketplace_path = Path . join ( repo_root , ".agents/plugins/marketplace.json" )
4656
@@ -89,7 +99,10 @@ defmodule Codex.Plugins.WriterTest do
8999 end
90100
91101 test "overwrite updates preserve unknown fields on the replaced marketplace entry" do
92- temp_root = temp_root ( "plugin_writer_overwrite_preserve" )
102+ temp_root =
103+ TempDir . create! ( "plugin_writer_overwrite_preserve" )
104+ |> tap ( & on_exit ( fn -> File . rm_rf! ( & 1 ) end ) )
105+
93106 repo_root = Path . join ( temp_root , "repo" )
94107 marketplace_path = Path . join ( repo_root , ".agents/plugins/marketplace.json" )
95108
@@ -157,12 +170,4 @@ defmodule Codex.Plugins.WriterTest do
157170 }
158171 ] = marketplace . plugins
159172 end
160-
161- defp temp_root ( prefix ) do
162- Path . join ( System . tmp_dir! ( ) , "#{ prefix } _#{ unique_suffix ( ) } " )
163- end
164-
165- defp unique_suffix do
166- Base . encode16 ( :crypto . strong_rand_bytes ( 8 ) , case: :lower )
167- end
168173end
0 commit comments