tarakan/test/support/fixtures/work_fixtures.ex
Maxfield Luke af6077b9c3
All checks were successful
CI and deploy / Test (push) Successful in 4m52s
CI and deploy / Deploy production (push) Successful in 23s
Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at
https://git.elektrine.com/elektrine/tarakan.
2026-07-29 04:43:40 -04:00

45 lines
1.3 KiB
Elixir

defmodule Tarakan.WorkFixtures do
@moduledoc """
Test helpers for the public review work queue.
"""
alias Tarakan.Work
def proposed_review_task_fixture(repository, creator, overrides \\ %{}) do
{:ok, task} =
Work.create_task(repository, creator, valid_review_task_attributes(overrides))
task
end
def valid_review_task_attributes(overrides \\ %{}) do
Enum.into(overrides, %{
"commit_sha" => Tarakan.ScansFixtures.random_commit_sha(),
"kind" => "threat_model",
"capability" => "human",
"title" => "Map the authorization boundary",
"description" => "Trace organization membership checks and document trust assumptions."
})
end
def review_task_fixture(repository, creator, overrides \\ %{}) do
task = proposed_review_task_fixture(repository, creator, overrides)
publisher = Tarakan.AccountsFixtures.account_fixture()
publisher =
publisher
|> Tarakan.Accounts.Account.authorization_changeset(%{
state: "active",
platform_role: "moderator",
trust_tier: "reviewer"
})
|> Tarakan.Repo.update!()
{:ok, task} =
Work.publish_task(task, publisher, %{
"reason" => "The task has a bounded, safe, and useful review scope."
})
task
end
end