-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e23eb8c
commit 0623fe4
Showing
4 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from masonite.tests import TestCase | ||
from masoniteorm.query import QueryBuilder | ||
from tests.integrations.app.models.User import User | ||
from masonite.facades import Hash | ||
|
||
|
||
class TestAudit(TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
QueryBuilder().table("audit_logs").truncate(True) | ||
QueryBuilder().table("users").truncate(True) | ||
|
||
def tearDown(self): | ||
super().tearDown() | ||
QueryBuilder().table("audit_logs").truncate(True) | ||
QueryBuilder().table("users").truncate(True) | ||
|
||
def test_audit_created(self): | ||
user = User.create({ | ||
"name": "Yubaraj", | ||
"email": "user@example.com", | ||
"password": Hash.make("secret"), | ||
"phone": "+123456789", | ||
}) | ||
|
||
self.assertDatabaseHas( | ||
"users", | ||
{ | ||
"email": "user@example.com", | ||
}, | ||
) | ||
|
||
self.assertDatabaseHas( | ||
"audit_logs", | ||
{ | ||
"model_id": user.id, | ||
"model_name": "users", | ||
"action": "CREATED", | ||
} | ||
) |