You've already forked tribes-plugin-aether
forked from tribes/tribes-plugin-template
Rename to aether plugin and add /aether timeline integration
This commit is contained in:
27
test/aether/host_integration_test.exs
Normal file
27
test/aether/host_integration_test.exs
Normal file
@@ -0,0 +1,27 @@
|
||||
defmodule Aether.HostIntegrationTest do
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
setup do
|
||||
start_supervised!({Tribes.PluginRegistry, []})
|
||||
|
||||
spec = Tribes.Plugins.Aether.Plugin.register(%{pubsub: nil, repo: nil})
|
||||
:ok = Tribes.PluginRegistry.register_plugin(spec.name, spec, "/tmp/aether")
|
||||
|
||||
on_exit(fn ->
|
||||
:ok = Tribes.PluginRegistry.unregister_plugin(spec.name)
|
||||
end)
|
||||
|
||||
%{spec: spec}
|
||||
end
|
||||
|
||||
test "registers timeline capability and /aether route with host", %{spec: spec} do
|
||||
assert spec.name == "aether"
|
||||
assert %{name: "aether"} = Tribes.PluginRegistry.provider!("timeline_ui@1")
|
||||
|
||||
assert {:ok, "aether", %{path: "/aether"}} =
|
||||
Tribes.PluginRegistry.page_for_path("/aether/tribe-123")
|
||||
|
||||
assert TribesWeb.Navigation.timeline_base_path() == "/aether"
|
||||
assert TribesWeb.Navigation.timeline_path("tribe-123") == "/aether/tribe-123"
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule MyPlugin.ManifestTest do
|
||||
defmodule Aether.ManifestTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
@manifest_path Path.join(__DIR__, "../../manifest.json") |> Path.expand()
|
||||
@@ -15,7 +15,15 @@ defmodule MyPlugin.ManifestTest do
|
||||
end
|
||||
|
||||
test "has required fields", %{manifest: manifest} do
|
||||
required = ["name", "version", "entry_module", "host_api", "provides", "requires"]
|
||||
required = [
|
||||
"name",
|
||||
"version",
|
||||
"entry_module",
|
||||
"host_api",
|
||||
"otp_app",
|
||||
"provides",
|
||||
"requires"
|
||||
]
|
||||
|
||||
for field <- required do
|
||||
assert Map.has_key?(manifest, field),
|
||||
@@ -24,13 +32,18 @@ defmodule MyPlugin.ManifestTest do
|
||||
end
|
||||
|
||||
test "name matches OTP app name", %{manifest: manifest} do
|
||||
assert manifest["name"] == "my_plugin"
|
||||
assert manifest["name"] == "aether"
|
||||
assert manifest["otp_app"] == manifest["name"]
|
||||
end
|
||||
|
||||
test "entry_module is a valid Elixir module name", %{manifest: manifest} do
|
||||
test "entry_module uses Tribes.Plugins namespace and Plugin suffix", %{manifest: manifest} do
|
||||
module_name = manifest["entry_module"]
|
||||
assert is_binary(module_name)
|
||||
assert String.starts_with?(module_name, "Elixir.") or not String.contains?(module_name, " ")
|
||||
|
||||
assert Regex.match?(
|
||||
~r/^Tribes\.Plugins\.[A-Z][A-Za-z0-9_]*(\.[A-Z][A-Za-z0-9_]*)*\.Plugin$/,
|
||||
module_name
|
||||
)
|
||||
end
|
||||
|
||||
test "provides contains valid capability identifiers", %{manifest: manifest} do
|
||||
@@ -53,7 +66,9 @@ defmodule MyPlugin.ManifestTest do
|
||||
|
||||
test "entry_module matches actual plugin module", %{manifest: manifest} do
|
||||
module = String.to_atom("Elixir.#{manifest["entry_module"]}")
|
||||
assert Code.ensure_loaded?(module), "entry_module #{manifest["entry_module"]} must be loadable"
|
||||
|
||||
assert Code.ensure_loaded?(module),
|
||||
"entry_module #{manifest["entry_module"]} must be loadable"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,14 +1,14 @@
|
||||
defmodule MyPlugin.PluginTest do
|
||||
defmodule Aether.PluginTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
describe "register/1" do
|
||||
setup do
|
||||
context = %{pubsub: nil, repo: nil}
|
||||
%{spec: MyPlugin.Plugin.register(context)}
|
||||
%{spec: Aether.Plugin.register(context)}
|
||||
end
|
||||
|
||||
test "returns plugin name and version", %{spec: spec} do
|
||||
assert spec.name == "my_plugin"
|
||||
assert spec.name == "aether"
|
||||
assert is_binary(spec.version)
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
defmodule MyPlugin.ContractTest do
|
||||
defmodule Aether.ContractTest do
|
||||
@moduledoc """
|
||||
Contract compliance tests.
|
||||
|
||||
@@ -6,10 +6,10 @@ defmodule MyPlugin.ContractTest do
|
||||
When Tribes.Plugin.ContractTest is available (host dep loaded),
|
||||
replace this file with:
|
||||
|
||||
defmodule MyPlugin.ContractTest do
|
||||
defmodule Aether.ContractTest do
|
||||
use Tribes.Plugin.ContractTest,
|
||||
plugin: MyPlugin.Plugin,
|
||||
otp_app: :my_plugin
|
||||
plugin: Tribes.Plugins.Aether.Plugin,
|
||||
otp_app: :aether
|
||||
end
|
||||
|
||||
Until then, this file provides a standalone equivalent.
|
||||
@@ -17,7 +17,7 @@ defmodule MyPlugin.ContractTest do
|
||||
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
@plugin MyPlugin.Plugin
|
||||
@plugin Tribes.Plugins.Aether.Plugin
|
||||
@manifest_path Path.join(__DIR__, "../manifest.json") |> Path.expand()
|
||||
|
||||
setup_all do
|
||||
|
||||
Reference in New Issue
Block a user