Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Clivern committed Mar 3, 2024
1 parent d52fd9a commit 45cfc92
Show file tree
Hide file tree
Showing 10 changed files with 1,471 additions and 80 deletions.
7 changes: 4 additions & 3 deletions lib/bandit/context/config_context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ defmodule Bandit.Context.ConfigContext do
"""

import Ecto.Query

alias Bandit.Repo
alias Bandit.Model.Config

@doc """
Get a new config
"""
def new_config(config \\ %{}) do
def new_config(attrs \\ %{}) do
%{
name: config.name,
value: config.value,
name: attrs.name,
value: attrs.value,
uuid: Ecto.UUID.generate()
}
end
Expand Down
9 changes: 5 additions & 4 deletions lib/bandit/context/team_context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ defmodule Bandit.Context.TeamContext do
"""

import Ecto.Query

alias Bandit.Repo
alias Bandit.Model.{Team, TeamMeta}

@doc """
Get a new team
"""
def new_team(team \\ %{}) do
def new_team(attrs \\ %{}) do
%{
slug: team.slug,
name: team.name,
description: team.description,
slug: attrs.slug,
name: attrs.name,
description: attrs.description,
uuid: Ecto.UUID.generate()
}
end
Expand Down
16 changes: 8 additions & 8 deletions lib/bandit/context/user_context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ defmodule Bandit.Context.UserContext do
@doc """
Get a new user
"""
def new_user(user \\ %{}) do
def new_user(attrs \\ %{}) do
%{
email: user.email,
name: user.name,
password_hash: user.password_hash,
verified: user.verified,
last_seen: user.last_seen,
role: user.role,
api_key: user.api_key,
email: attrs.email,
name: attrs.name,
password_hash: attrs.password_hash,
verified: attrs.verified,
last_seen: attrs.last_seen,
role: attrs.role,
api_key: attrs.api_key,
uuid: Ecto.UUID.generate()
}
end
Expand Down
9 changes: 8 additions & 1 deletion test/bandit/context/config_context_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ defmodule Bandit.Context.ConfigContextTest do
@moduledoc """
Lock Context Test Cases
"""
use Bandit.DataCase

use ExUnit.Case

alias Bandit.Context.ConfigContext, as: ConfigContext

# Init
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Brandit.Repo)
end

describe "new_config/1" do
# new_config/1
test "new_config/1 test cases" do
Expand Down
8 changes: 7 additions & 1 deletion test/bandit/context/env_context_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ defmodule Bandit.Context.EnvironmentContextTest do
@moduledoc """
Environment Context Test Cases
"""
use Bandit.DataCase

use ExUnit.Case

alias Bandit.Context.EnvironmentContext
alias Bandit.Context.ProjectContext
alias Bandit.Context.TeamContext

# Init
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Brandit.Repo)
end

describe "new_env/1" do
test "returns a new environment with a UUID" do

Check failure on line 22 in test/bandit/context/env_context_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25.1 / Elixir 1.14.3

test new_env/1 returns a new environment with a UUID (Bandit.Context.EnvironmentContextTest)

Check failure on line 22 in test/bandit/context/env_context_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25.1 / Elixir 1.14.4

test new_env/1 returns a new environment with a UUID (Bandit.Context.EnvironmentContextTest)

Check failure on line 22 in test/bandit/context/env_context_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25.1 / Elixir 1.14.5

test new_env/1 returns a new environment with a UUID (Bandit.Context.EnvironmentContextTest)
team_item =
Expand Down
13 changes: 13 additions & 0 deletions test/bandit/context/lock_context.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Copyright 2023 Clivern. All rights reserved.
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file.

defmodule Bandit.Context.LockContextTest do
@moduledoc """
Lock Context Test Cases
"""

use ExUnit.Case

alias Bandit.Context.LockContext

# Init
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Brandit.Repo)
end

describe "new_lock/1" do
test "returns a new lock" do
lock =
Expand Down
13 changes: 13 additions & 0 deletions test/bandit/context/project_context.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Copyright 2023 Clivern. All rights reserved.
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file.

defmodule Bandit.Context.ProjectContextTest do
@moduledoc """
Project Context Test Cases
"""

use ExUnit.Case

alias Bandit.Context.ProjectContext

# Init
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Brandit.Repo)
end

describe "new_project/1" do
test "returns a new project" do
team_item =
Expand Down
13 changes: 13 additions & 0 deletions test/bandit/context/state_context.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# Copyright 2023 Clivern. All rights reserved.
# Use of this source code is governed by the MIT
# license that can be found in the LICENSE file.

defmodule Bandit.Context.StateContextTest do
@moduledoc """
State Context Test Cases
"""

use ExUnit.Case

alias Bandit.Context.StateContext

# Init
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Brandit.Repo)
end

describe "new_state/1" do
test "returns a new state" do
state = StateContext.new_state(%{name: "State 1", value: "Value 1", project_id: 1})
Expand Down
Loading

0 comments on commit 45cfc92

Please sign in to comment.