defmodule Firehose.MutationScopeTest do # The app's candidate pure modules (Firehose.Accounts.User, Scope and # UserToken) are only exercised through Firehose.DataCase: their tests use # the SQL sandbox, fixtures and Repo. Per the yak's Q45 decision, an app # mutation run would therefore need PostgreSQL, so the scope is deliberately # empty and the alias fails loudly rather than silently running over nothing. # # These pins keep that decision visible: if the scope grows, this file must # change with it, and it may never grow into the web layer. use ExUnit.Case @root Path.expand("..", __DIR__) test "scope files exist" do assert File.exists?(Path.join(@root, "mutation_scope.txt")) assert File.exists?(Path.join(@root, "mutation_scope_fast.txt")) end test "app scope is empty because the candidate modules' tests need PostgreSQL" do assert scope("mutation_scope.txt") == [] end test "fast scope is a subset of full scope" do out_of_scope = MapSet.difference( MapSet.new(scope("mutation_scope_fast.txt")), MapSet.new(scope("mutation_scope.txt")) ) assert MapSet.size(out_of_scope) == 0, "mutate.fast names files outside the audited scope: #{inspect(MapSet.to_list(out_of_scope))}" end test "scope never includes web-layer code" do web_entries = Enum.filter( scope("mutation_scope.txt") ++ scope("mutation_scope_fast.txt"), &String.starts_with?(&1, "lib/firehose_web") ) assert web_entries == [], "the web layer (controllers, LiveViews, components) is out of scope: #{inspect(web_entries)}" end defp scope(file) do @root |> Path.join(file) |> File.read!() |> String.split("\n", trim: true) |> Enum.map(&String.trim/1) |> Enum.reject(&(&1 == "")) end end