diff --git a/test/install_version_test.exs b/test/install_version_test.exs new file mode 100644 index 0000000..d135013 --- /dev/null +++ b/test/install_version_test.exs @@ -0,0 +1,27 @@ +defmodule InstallVersionTest do + use ExUnit.Case, async: true + + describe("install version check") do + test "README.md" do + assert_version("README.md") + end + end + + defp assert_version(filename) do + app = Keyword.get(Mix.Project.config(), :app) + app_version = app |> Application.spec(:vsn) |> to_string() + + file = File.read!(filename) + [_, file_versions] = Regex.run(~r/{:#{app}, "(.+)"}/, file) + + assert Version.match?( + app_version, + file_versions + ), + """ + Install version constraint in `#{filename}` does not match to current app version. + Current App Version: #{app_version} + `#{filename}` Install Versions: #{file_versions} + """ + end +end