Skip to main content
Glama
data_case.ex1.19 kB
defmodule HexdocsMcp.DataCase do @moduledoc """ This module defines the setup for tests requiring access to the application's data layer. You may define functions here to be used as helpers in your tests. """ use ExUnit.CaseTemplate alias Ecto.Adapters.SQL.Sandbox using do quote do import Ecto import Ecto.Changeset import Ecto.Query import ExUnit.CaptureIO import HexdocsMcp.DataCase import HexdocsMcp.Fixtures alias HexdocsMcp.Repo end end setup tags do Mox.stub_with(HexdocsMcp.MockOllama, HexdocsMcp.MockOllamaClient) Mox.stub_with(HexdocsMcp.MockDocs, HexdocsMcp.MockHexdocsCli) :ok = Sandbox.checkout(HexdocsMcp.Repo) if !tags[:async] do Sandbox.mode(HexdocsMcp.Repo, {:shared, self()}) end HexdocsMcp.SqlSandbox.setup() :ok end @doc """ A helper that transforms changeset errors into a map of messages. """ def errors_on(changeset) do Ecto.Changeset.traverse_errors(changeset, fn {msg, opts} -> Regex.replace(~r"%{(\w+)}", msg, fn _, key -> opts |> Keyword.get(String.to_existing_atom(key), key) |> to_string() end) end) end end

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bradleygolden/hexdocs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server