diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-03-23 17:11:39 +0100 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-04-05 21:16:51 +0200 |
| commit | 0ab2e5ba2b0631b28b5b1405559237b3913c878f (patch) | |
| tree | 791cea788b0a62bc483d0041fbd0c655d2ad49e8 /test/support/fixtures/users_fixtures.ex | |
feat: initialize Phoenix application for weather alerts
This commit sets up the initial Silmataivas project structure, including: Phoenix web framework configuration, database models for users and locations, weather polling service, notification system, Docker and deployment configurations, CI/CD pipeline setup
Diffstat (limited to 'test/support/fixtures/users_fixtures.ex')
| -rw-r--r-- | test/support/fixtures/users_fixtures.ex | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/support/fixtures/users_fixtures.ex b/test/support/fixtures/users_fixtures.ex new file mode 100644 index 0000000..8c26ab5 --- /dev/null +++ b/test/support/fixtures/users_fixtures.ex @@ -0,0 +1,41 @@ +defmodule Silmataivas.UsersFixtures do + @moduledoc """ + This module defines test helpers for creating + entities via the `Silmataivas.Users` context. + """ + + @doc """ + Generate a unique user user_id. + """ + def unique_user_user_id, do: "some user_id#{System.unique_integer([:positive])}" + + @doc """ + Generate a user. + """ + def user_fixture(attrs \\ %{}) do + {:ok, user} = + attrs + |> Enum.into(%{ + role: "user", + user_id: unique_user_user_id() + }) + |> Silmataivas.Users.create_user() + + user + end + + @doc """ + Generate an admin user. + """ + def admin_fixture(attrs \\ %{}) do + {:ok, user} = + attrs + |> Enum.into(%{ + role: "admin", + user_id: unique_user_user_id() + }) + |> Silmataivas.Users.create_user() + + user + end +end |
