-
Notifications
You must be signed in to change notification settings - Fork 83
Improve test coverage for database package #1372
Conversation
// app. Note that the API key is NOT stored in the database, only a hash. The | ||
// only time the API key is available is as the string return parameter from | ||
// invoking this function. | ||
func (r *Realm) CreateAuthorizedApp(db *Database, app *AuthorizedApp, actor Auditable) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into Realm
// CreateCleanup is used to create a new 'cleanup' type/row in the database. | ||
func (db *Database) CreateCleanup(cType string) (*CleanupStatus, error) { | ||
cstat := &CleanupStatus{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐉 t'was a sad bug here
@@ -38,11 +38,3 @@ type SigningKey struct { | |||
func (s *SigningKey) GetKID() string { | |||
return fmt.Sprintf("r%dv%d", s.RealmID, s.ID) | |||
} | |||
|
|||
func (s *SigningKey) Delete(db *Database) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are both unused
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sethvargo, whaught The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -63,6 +66,32 @@ type AuditEntry struct { | |||
CreatedAt time.Time | |||
} | |||
|
|||
// BeforeSave runs validations. If there are errors, the save fails. | |||
func (a *AuditEntry) BeforeSave(tx *gorm.DB) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we worry about this causing runtime failures for other actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields are NOT NULL in the database. A runtime error would already have existed, just with a pgx_violated_contstraint response instead.
Fixes #1296
Release Note