- Sort source files by mtime (newest first) and take only the first 2 - This limits the page scope for easier testing/investigation - Temporary limit; will be 10 most recently changed files later - Updated tests to work with the 2-file limit
68 lines
2.2 KiB
Elixir
68 lines
2.2 KiB
Elixir
defmodule FirehoseWeb.MicroprintsLiveTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
describe "scan_source_files/0" do
|
|
test "returns exactly 2 files" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
assert length(files) == 2
|
|
end
|
|
|
|
test "returns only .ex files from app/ and blogex/ directories" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
# With the 2-file limit, check that returned files are valid .ex paths
|
|
Enum.each(files, fn file ->
|
|
assert String.ends_with?(file, ".ex")
|
|
assert String.starts_with?(file, "lib/") or String.starts_with?(file, "../blogex/")
|
|
end)
|
|
end
|
|
|
|
test "does not include files from _build/ directory" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
refute Enum.any?(files, &String.starts_with?(&1, "_build/"))
|
|
end
|
|
|
|
test "does not include files from deps/ directory" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
refute Enum.any?(files, &String.starts_with?(&1, "deps/"))
|
|
end
|
|
|
|
test "does not include files from examples/ directory" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
refute Enum.any?(files, &String.contains?(&1, "/examples/"))
|
|
end
|
|
|
|
test "does not include test files" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
refute Enum.any?(files, &String.contains?(&1, "/test/"))
|
|
end
|
|
|
|
test "paths are relative (no leading slash or absolute path)" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
refute Enum.any?(files, &String.starts_with?(&1, "/"))
|
|
end
|
|
|
|
test "app paths do not contain source dir prefix" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
app_files = Enum.filter(files, &String.starts_with?(&1, "lib/"))
|
|
refute Enum.any?(app_files, &String.starts_with?(&1, "app/"))
|
|
end
|
|
|
|
test "blogex paths start with ../blogex/" do
|
|
files = FirehoseWeb.MicroprintsLive.scan_source_files()
|
|
|
|
blogex_files = Enum.filter(files, &String.starts_with?(&1, "../blogex/"))
|
|
# With the 2-file limit, blogex files may or may not be included
|
|
# depending on which files are most recently modified
|
|
assert is_list(blogex_files)
|
|
end
|
|
end
|
|
end
|