From 77f89e6b0d49d33a65561e9d674c0ebedd68af94 Mon Sep 17 00:00:00 2001 From: Gabrielparizet Date: Tue, 4 Jun 2024 00:37:19 +0200 Subject: [PATCH] wip(accounts): trying to cover for Accounts.update_account() --- test/book_my_gigs/accounts/accounts_test.exs | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/book_my_gigs/accounts/accounts_test.exs diff --git a/test/book_my_gigs/accounts/accounts_test.exs b/test/book_my_gigs/accounts/accounts_test.exs new file mode 100644 index 0000000..6d1e8c7 --- /dev/null +++ b/test/book_my_gigs/accounts/accounts_test.exs @@ -0,0 +1,42 @@ +defmodule BookMyGigs.Accounts.AccountsTest do + use BookMyGigs.DataCase, async: true + doctest BookMyGigs + + alias BookMyGigs.Repo + alias BookMyGigs.Accounts + alias BookMyGigs.Accounts.Storage + + test "update_accounts can update an email and/or a password" do + account = + %Storage.Account{ + email: "test@gmail.com", + hash_password: "ThisIsMyPassword123?" + } + |> Repo.insert!() + + + email_params = %{ + "account" => %{ + "email" => "modified_email@gmail.com", + } + } + + assert Accounts.update_account(email_params, account.id) == + %Accounts.Account{ + :email => "modified_email@gmail.com", + :hash_password => "ThisIsMyPassword123?" + } + + hash_password_params = %{ + "account" => %{ + "hash_password" => "ModifiedPassword123?" + } + } + + assert Accounts.update_account(hash_password_params, account.id) == + %Accounts.Account{ + :email => "modified_email@gmail.com", + :hash_password => "ModifiedPassword123?" + } + end +end