feat(agent): add [debug] dump_dir config field

This commit is contained in:
Carsten 2026-04-22 22:15:01 +02:00
parent b798b462ca
commit 1c289a5a0d
3 changed files with 49 additions and 0 deletions

View file

@ -6,3 +6,6 @@ host_id = "pve-test-01"
fast_seconds = 15
medium_seconds = 120
slow_seconds = 600
[debug]
dump_dir = "/tmp/proxmox-monitor-test"

View file

@ -14,6 +14,43 @@ defmodule ProxmoxAgent.ConfigTest do
assert cfg.fast_seconds == 15
assert cfg.medium_seconds == 120
assert cfg.slow_seconds == 600
assert cfg.dump_dir == "/tmp/proxmox-monitor-test"
end
test "parses [debug] dump_dir when present" do
assert {:ok, cfg} = Config.load(@fixture)
assert cfg.dump_dir == "/tmp/proxmox-monitor-test"
end
test "dump_dir is nil when [debug] is absent" do
tmp = Path.join(System.tmp_dir!(), "agent_nodebug.toml")
File.write!(tmp, """
server_url = "wss://x/socket/websocket"
token = "t"
""")
on_exit(fn -> File.rm(tmp) end)
assert {:ok, cfg} = Config.load(tmp)
assert cfg.dump_dir == nil
end
test "dump_dir is nil when set to empty string" do
tmp = Path.join(System.tmp_dir!(), "agent_emptydebug.toml")
File.write!(tmp, """
server_url = "wss://x/socket/websocket"
token = "t"
[debug]
dump_dir = ""
""")
on_exit(fn -> File.rm(tmp) end)
assert {:ok, cfg} = Config.load(tmp)
assert cfg.dump_dir == nil
end
test "returns error for missing file" do