From 4bb32f9757c5a1e25ecb333748bbb756a14a75d8 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Fri, 6 Jun 2025 16:29:11 -0300 Subject: [PATCH] feat(repo,users): add assertions check for struct values --- repository/users.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/repository/users.go b/repository/users.go index 2421e1f..11176ff 100644 --- a/repository/users.go +++ b/repository/users.go @@ -27,6 +27,7 @@ func NewUserRepository( assert tinyssert.Assertions, ) (*UserRepository, error) { assert.NotNil(db) + assert.NotNil(ctx) assert.NotNil(logger) _, err := db.Exec(`CREATE TABLE IF NOT EXISTS users ( @@ -48,6 +49,10 @@ func NewUserRepository( } func (r *UserRepository) Create(u model.User) (model.User, error) { + r.assert.NotNil(r.db) + r.assert.NotNil(r.log) + r.assert.NotNil(r.ctx) + tx, err := r.db.BeginTx(r.ctx, nil) if err != nil { return model.User{}, err @@ -84,6 +89,10 @@ func (r *UserRepository) Create(u model.User) (model.User, error) { } func (r *UserRepository) GetByUsername(username string) (model.User, error) { + r.assert.NotNil(r.db) + r.assert.NotNil(r.log) + r.assert.NotNil(r.ctx) + tx, err := r.db.BeginTx(r.ctx, nil) if err != nil { return model.User{}, err @@ -133,6 +142,10 @@ func (r *UserRepository) GetByUsername(username string) (model.User, error) { } func (r *UserRepository) Delete(u model.User) error { + r.assert.NotNil(r.db) + r.assert.NotNil(r.log) + r.assert.NotNil(r.ctx) + tx, err := r.db.BeginTx(r.ctx, nil) if err != nil { return err