chore: cleaned up bang-Operator usage

This commit is contained in:
2026-05-01 16:56:21 +02:00
parent 7f5077c6ad
commit a95e9482a7
13 changed files with 459 additions and 266 deletions

View File

@@ -910,6 +910,20 @@ defmodule BDS.GenerationTest do
assert clean_report.updated_post_url_paths == []
end
test "apply_validation returns an error for unreadable generated files", %{
project: project,
temp_dir: temp_dir
} do
unreadable_path = Path.join([temp_dir, "html", "obsolete", "index.html"])
File.mkdir_p!(Path.dirname(unreadable_path))
File.write!(unreadable_path, "<html>obsolete</html>")
File.chmod!(unreadable_path, 0o000)
on_exit(fn -> File.chmod!(unreadable_path, 0o644) end)
assert {:error, {:read_generated_file, ^unreadable_path, :eacces}} =
BDS.Generation.apply_validation(project.id, [:core])
end
test "validate_site regenerates sitemap and reports missing, extra, and updated post url paths",
%{project: project, temp_dir: temp_dir} do
assert {:ok, _metadata} =

View File

@@ -99,6 +99,28 @@ defmodule BDS.MCPAgentConfigTest do
assert written["mcpServers"]["other"] == %{"command" => "python", "args" => ["server.py"]}
end
test "add_to_config returns an error for unreadable existing config", %{home_dir: home_dir} do
config_path = Path.join(home_dir, ".claude.json")
File.mkdir_p!(config_path)
assert {:error, {:read_config, ^config_path, :eisdir}} =
AgentConfig.add_to_config(:claude_code,
home_dir: home_dir,
install_root: Path.join(home_dir, "dist"),
platform: :linux
)
end
test "remove_from_config returns an error for unwritable config path", %{home_dir: home_dir} do
config_path = Path.join(home_dir, ".claude.json")
File.chmod!(home_dir, 0o555)
on_exit(fn -> File.chmod!(home_dir, 0o755) end)
assert {:error, {:write_config, ^config_path, :eacces}} =
AgentConfig.remove_from_config(:claude_code, home_dir: home_dir)
end
test "packaged executable path resolves inside the distributable payload" do
assert AgentConfig.packaged_executable_path("/Applications/bDS2.app/Contents/Resources", :macos) ==
"/Applications/bDS2.app/Contents/Resources/mcp/bin/bds-mcp"

View File

@@ -325,6 +325,23 @@ defmodule BDS.MediaTest do
end)
end
test "rebuild_media_from_files returns an error for unreadable sidecars", %{
project: project,
temp_dir: temp_dir
} do
media_dir = Path.join([temp_dir, "media", "2026", "04"])
File.mkdir_p!(media_dir)
binary_path = Path.join(media_dir, "asset.jpg")
sidecar_path = binary_path <> ".meta"
File.write!(binary_path, tiny_jpeg_binary())
File.mkdir_p!(sidecar_path)
assert {:error, {:read_sidecar, ^sidecar_path, :eisdir}} =
BDS.Media.rebuild_media_from_files(project.id)
end
test "import_media generates the four thumbnail files in bucketed thumbnail paths", %{
project: project,
temp_dir: temp_dir

View File

@@ -458,6 +458,17 @@ defmodule BDS.PostsTest do
assert post.published_at == 1_036_497_600_000
end
test "rebuild_posts_from_files returns an error for unreadable post files", %{project: project} do
posts_dir = Path.join([BDS.Projects.project_data_dir(project), "posts", "2026", "04"])
File.mkdir_p!(posts_dir)
file_path = Path.join(posts_dir, "unreadable.md")
File.mkdir_p!(file_path)
assert {:error, {:read_rebuild_file, ^file_path, :eisdir}} =
BDS.Posts.rebuild_posts_from_files(project.id)
end
test "rebuild_posts_from_files parses folded multiline title and slug scalars alongside translations" do
temp_dir =
Path.join(System.tmp_dir!(), "bds-post-rebuild-folded-#{System.unique_integer([:positive])}")