test(tools): add unit tests for error handling functions

* Implement tests for error functions like errRequiredField, errInvalidField, and errEntityNotFound.
* Ensure proper metadata is returned for various error scenarios.
* Validate error handling in CRM, Files, and other tools.
* Introduce tests for parsing stored file IDs and UUIDs.
* Enhance coverage for helper functions related to project resolution and session management.
This commit is contained in:
Hein
2026-03-31 15:10:07 +02:00
parent acd780ac9c
commit f41c512f36
54 changed files with 1937 additions and 365 deletions

View File

@@ -136,7 +136,9 @@ func (db *DB) AddThoughtAttachment(ctx context.Context, thoughtID uuid.UUID, att
if err != nil {
return fmt.Errorf("begin transaction: %w", err)
}
defer tx.Rollback(ctx)
defer func() {
_ = tx.Rollback(ctx)
}()
var metadataBytes []byte
if err := tx.QueryRow(ctx, `select metadata from thoughts where guid = $1 for update`, thoughtID).Scan(&metadataBytes); err != nil {

View File

@@ -25,7 +25,9 @@ func (db *DB) InsertThought(ctx context.Context, thought thoughttypes.Thought, e
if err != nil {
return thoughttypes.Thought{}, fmt.Errorf("begin transaction: %w", err)
}
defer tx.Rollback(ctx)
defer func() {
_ = tx.Rollback(ctx)
}()
row := tx.QueryRow(ctx, `
insert into thoughts (content, metadata, project_id)
@@ -240,7 +242,9 @@ func (db *DB) UpdateThought(ctx context.Context, id uuid.UUID, content string, e
if err != nil {
return thoughttypes.Thought{}, fmt.Errorf("begin transaction: %w", err)
}
defer tx.Rollback(ctx)
defer func() {
_ = tx.Rollback(ctx)
}()
tag, err := tx.Exec(ctx, `
update thoughts