Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Improve test coverage for database package #1372

Merged
merged 1 commit into from
Dec 15, 2020
Merged

Conversation

sethvargo
Copy link
Member

Fixes #1296

Release Note

Improve database test coverage

@google-cla google-cla bot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Dec 15, 2020
// 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) {
Copy link
Member Author

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{
Copy link
Member Author

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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are both unused

@google-oss-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit 494b99e into main Dec 15, 2020
@google-oss-robot google-oss-robot deleted the sethvargo/db_tests branch December 15, 2020 22:05
@@ -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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

increase test coverage in pkg/database
4 participants