yak(credo-strict-tuned-config-both-apps-x02d): credo strict, tuned config (both apps)

This commit is contained in:
Willem van den Ende
2026-10-29 10:13:02 +00:00
parent 13e3186f58
commit ef8407b272
13 changed files with 502 additions and 35 deletions
+44
View File
@@ -0,0 +1,44 @@
defmodule Blogex.LinkErrorTest do
@moduledoc """
Pins the rendered exception message, not just the struct.
The message is what a compile-time failure shows a human: the indentation and
the newline between errors are load-bearing. This is a characterization test
written before `message/1` was rewritten (`Enum.map/2 |> Enum.join/2` ->
`Enum.map_join/3`), so it passes on both sides of that change by design - it
exists to make the rewrite safe, not to prove new behaviour.
"""
use ExUnit.Case, async: true
test "message/1 renders one indented line per error" do
error = %Blogex.LinkError{
blog: :engineering,
post_id: "my-post",
errors: [
{1, "/blog/unknown/broken", "unknown blog ID: unknown", [post_id: "my-post"]},
{7, "/blog/engineering/", "empty slug", [post_id: "my-post"]}
]
}
assert Exception.message(error) == """
invalid internal blog links in engineering (post: my-post)
line 1: /blog/unknown/broken — unknown blog ID: unknown
line 7: /blog/engineering/ — empty slug
"""
end
test "message/1 omits the post label when there is no post id" do
error = %Blogex.LinkError{
blog: :engineering,
post_id: nil,
errors: [{3, "/blog/unknown/broken", "unknown blog ID: unknown", []}]
}
assert Exception.message(error) == """
invalid internal blog links in engineering
line 3: /blog/unknown/broken — unknown blog ID: unknown
"""
end
end