yak(behavior-tests-blogex-public-api-and-router-plumbing-q1fb): behavior tests: blogex public API and router plumbing

This commit is contained in:
Willem van den Ende
2026-10-28 22:15:02 +00:00
parent c04d8c856c
commit cc03cefe8d
9 changed files with 211 additions and 46 deletions
+49
View File
@@ -0,0 +1,49 @@
defmodule Blogex.Test.AlphaBlog do
@moduledoc """
A minimal blog module for cross-blog tests.
Implements the interface `Blogex.Registry` queries (and nothing else), so a
test can configure `:blogex, :blogs` with real modules without compiling a
`use Blogex.Blog` module or touching the filesystem.
`all_posts/0`/`unfiltered_posts/0` are hard-coded — the dates are literals so
tests can assert exact orderings rather than re-deriving them.
"""
def blog_id, do: :alpha
def all_posts,
do: [Blogex.Test.PostBuilder.build(id: "a1", date: ~D[2026-03-01], blog: :alpha)]
def all_tags, do: ["elixir"]
def unfiltered_posts,
do: [
Blogex.Test.PostBuilder.build(id: "a1", date: ~D[2026-03-01], blog: :alpha),
Blogex.Test.PostBuilder.build(
id: "a-draft",
date: ~D[2026-03-05],
blog: :alpha,
published: false
)
]
end
defmodule Blogex.Test.BetaBlog do
@moduledoc """
The second blog module for cross-blog tests; see `Blogex.Test.AlphaBlog`.
"""
def blog_id, do: :beta
def all_posts,
do: [Blogex.Test.PostBuilder.build(id: "b1", date: ~D[2026-03-15], blog: :beta)]
def all_tags, do: ["devops"]
def unfiltered_posts,
do: [
Blogex.Test.PostBuilder.build(id: "b1", date: ~D[2026-03-15], blog: :beta),
Blogex.Test.PostBuilder.build(id: "b-future", date: ~D[2099-01-01], blog: :beta)
]
end