60 lines
1.6 KiB
Elixir
60 lines
1.6 KiB
Elixir
defmodule Nulla.ActorsFixtures do
|
|
alias Nulla.KeyGen
|
|
|
|
@moduledoc """
|
|
This module defines test helpers for creating
|
|
entities via the `Nulla.Actors` context.
|
|
"""
|
|
|
|
@doc """
|
|
Generate a actor.
|
|
"""
|
|
def actor_fixture(attrs \\ %{}) do
|
|
username = "test#{System.unique_integer()}"
|
|
{publicKeyPem, privateKeyPem} = KeyGen.gen()
|
|
|
|
attrs =
|
|
Enum.into(attrs, %{
|
|
acct: "#{username}@localhost",
|
|
ap_id: "http://localhost/users/#{username}",
|
|
attachment: [],
|
|
discoverable: true,
|
|
endpoints: %{},
|
|
featured: "some featured",
|
|
featuredTags: "some featuredTags",
|
|
followers: "some followers",
|
|
following: "some following",
|
|
icon: %{},
|
|
image: %{},
|
|
inbox: "some inbox",
|
|
indexable: true,
|
|
manuallyApprovesFollowers: true,
|
|
memorial: true,
|
|
name: "some name",
|
|
outbox: "some outbox",
|
|
preferredUsername: username,
|
|
publicKey: %{
|
|
"id" => "http://localhost/users/#{username}#main-key",
|
|
"owner" => "http://localhost/users/#{username}",
|
|
"publicKeyPem" => publicKeyPem
|
|
},
|
|
privateKeyPem: privateKeyPem,
|
|
published: ~U[2025-06-30 13:31:00Z],
|
|
summary: "some summary",
|
|
tag: [],
|
|
type: "some type",
|
|
url: "some url",
|
|
vcard_Address: "some vcard_Address",
|
|
vcard_bday: ~D[2025-06-30]
|
|
})
|
|
|
|
case Nulla.Actors.create_actor(attrs) do
|
|
{:ok, actor} ->
|
|
actor
|
|
|
|
{:error, changeset} ->
|
|
IO.inspect(changeset, label: "Actor creation failed")
|
|
raise "Failed to create actor fixture"
|
|
end
|
|
end
|
|
end
|