Skip to content

Commit

Permalink
Add additional test to tags context
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Nov 20, 2023
1 parent 465f2ba commit f482ceb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/trento/tags_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ defmodule Trento.TagsTest do
assert nil == Repo.get_by(Tag, resource_id: resource_id)
end

test "add_tag/3 does nothing on conflict with resource_id and value" do
%Tag{value: value, resource_id: resource_id, resource_type: type} = insert(:tag)

{:ok, %Tag{id: nil, value: ^value, resource_id: ^resource_id, resource_type: :host}} =
Tags.add_tag(value, resource_id, type)

assert %Tag{value: ^value, resource_id: ^resource_id, resource_type: :host} =
Repo.get_by(Tag, resource_id: resource_id)
end

test "delete_tag/2 deletes a tag from a given resource" do
%Tag{value: value, resource_id: resource_id} = insert(:tag)
:ok = Tags.delete_tag(value, resource_id)
Expand Down

0 comments on commit f482ceb

Please sign in to comment.