Add AgentsFixtures tests
Added 4 tests covering all fixture functions: - unique_agent_name/0 generation - agent_token_fixture/2 with default and custom names - agent_assignment_fixture/2 creation Coverage increased from 40% to 100%. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
19953ae289
commit
0689fec38c
1 changed files with 67 additions and 0 deletions
67
test/support/fixtures/agents_fixtures_test.exs
Normal file
67
test/support/fixtures/agents_fixtures_test.exs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
defmodule Towerops.AgentsFixturesTest do
|
||||
use Towerops.DataCase
|
||||
|
||||
import Towerops.AccountsFixtures
|
||||
import Towerops.AgentsFixtures
|
||||
|
||||
describe "unique_agent_name/0" do
|
||||
test "generates unique agent names" do
|
||||
name1 = unique_agent_name()
|
||||
name2 = unique_agent_name()
|
||||
|
||||
assert name1 != name2
|
||||
assert name1 =~ "Test Agent"
|
||||
assert name2 =~ "Test Agent"
|
||||
end
|
||||
end
|
||||
|
||||
describe "agent_token_fixture/2" do
|
||||
test "creates an agent token with default name" do
|
||||
user = user_fixture()
|
||||
{:ok, organization} = Towerops.Organizations.create_organization(%{name: "Test Org"}, user.id)
|
||||
|
||||
{:ok, agent_token, token_string} = agent_token_fixture(organization.id)
|
||||
|
||||
assert agent_token.organization_id == organization.id
|
||||
assert agent_token.name =~ "Test Agent"
|
||||
assert is_binary(token_string)
|
||||
end
|
||||
|
||||
test "creates an agent token with custom name" do
|
||||
user = user_fixture()
|
||||
{:ok, organization} = Towerops.Organizations.create_organization(%{name: "Test Org"}, user.id)
|
||||
|
||||
{:ok, agent_token, _token_string} = agent_token_fixture(organization.id, "Custom Agent")
|
||||
|
||||
assert agent_token.name == "Custom Agent"
|
||||
end
|
||||
end
|
||||
|
||||
describe "agent_assignment_fixture/2" do
|
||||
test "creates an agent assignment" do
|
||||
user = user_fixture()
|
||||
{:ok, organization} = Towerops.Organizations.create_organization(%{name: "Test Org"}, user.id)
|
||||
|
||||
{:ok, site} =
|
||||
Towerops.Sites.create_site(%{
|
||||
name: "Test Site",
|
||||
organization_id: organization.id
|
||||
})
|
||||
|
||||
{:ok, equipment} =
|
||||
Towerops.Equipment.create_equipment(%{
|
||||
name: "Test Equipment",
|
||||
ip_address: "192.168.1.1",
|
||||
site_id: site.id
|
||||
})
|
||||
|
||||
{:ok, agent_token, _token_string} = agent_token_fixture(organization.id)
|
||||
|
||||
{:ok, assignment} = agent_assignment_fixture(agent_token.id, equipment.id)
|
||||
|
||||
assert assignment.agent_token_id == agent_token.id
|
||||
assert assignment.equipment_id == equipment.id
|
||||
assert assignment.enabled == true
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue