mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-22 08:01:00 +00:00
update delete_song/1 test
This commit is contained in:
parent
bd4d57377b
commit
b9b7a27244
1 changed files with 7 additions and 1 deletions
|
@ -56,11 +56,17 @@ defmodule LiveBeats.MediaLibraryTest do
|
||||||
assert song == MediaLibrary.get_song!(song.id)
|
assert song == MediaLibrary.get_song!(song.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "delete_song/1 deletes the song" do
|
test "delete_song/1 deletes the song and decrement the user's songs_count" do
|
||||||
user = user_fixture()
|
user = user_fixture()
|
||||||
|
|
||||||
|
user
|
||||||
|
|> Ecto.Changeset.change(songs_count: 10)
|
||||||
|
|> LiveBeats.Repo.update()
|
||||||
|
|
||||||
song = song_fixture(%{user_id: user.id})
|
song = song_fixture(%{user_id: user.id})
|
||||||
assert :ok = MediaLibrary.delete_song(song)
|
assert :ok = MediaLibrary.delete_song(song)
|
||||||
assert_raise Ecto.NoResultsError, fn -> MediaLibrary.get_song!(song.id) end
|
assert_raise Ecto.NoResultsError, fn -> MediaLibrary.get_song!(song.id) end
|
||||||
|
assert Accounts.get_user(user.id).songs_count == 9
|
||||||
end
|
end
|
||||||
|
|
||||||
test "change_song/1 returns a song changeset" do
|
test "change_song/1 returns a song changeset" do
|
||||||
|
|
Loading…
Reference in a new issue