db

package
v0.0.0-...-c92e1c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const SqlSelectUnsignedUsersForPR = `SELECT count(*) from unsigned_pr, unsigned_user
WHERE unsigned_pr.Id = unsigned_user.UnsignedPRID AND unsigned_pr.Id = $1`
View Source
const SqlSelectUserSignature = `SELECT 
		LoginName, Email, GivenName, SignedAt, ClaVersion 
		FROM signatures		
		WHERE LoginName = $1
		AND ClaVersion = $2`

Variables

This section is empty.

Functions

func ConvertSqlToDbMockExpect

func ConvertSqlToDbMockExpect(realSql string) string

ConvertSqlToDbMockExpect takes a "real" sql string and adds escape characters as needed to produce a regex matching string for use with database mock expect calls.

Types

type AnyTime

type AnyTime struct{}

func (AnyTime) Match

func (a AnyTime) Match(v driver.Value) bool

Match satisfies sqlmock.Argument interface

type ClaDB

type ClaDB struct {
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, logger *zap.Logger) *ClaDB

func SetupMockDB

func SetupMockDB(t *testing.T) (mock sqlmock.Sqlmock, mockDbIf *ClaDB, closeDbFunc func())

SetupMockDB should always be followed by a call to the closeDbFunc, like so:

mock, db, closeDbFunc := SetupMockDB(t)
defer closeDbFunc()

func (*ClaDB) GetPRsForUser

func (p *ClaDB) GetPRsForUser(user *types.UserSignature) (evalInfos []types.EvaluationInfo, err error)

func (*ClaDB) HasAuthorSignedTheCla

func (p *ClaDB) HasAuthorSignedTheCla(login, claVersion string) (isSigned bool, foundUserSignature *types.UserSignature, err error)

func (*ClaDB) InsertSignature

func (p *ClaDB) InsertSignature(user *types.UserSignature) error

func (*ClaDB) MigrateDB

func (p *ClaDB) MigrateDB(migrateSourceURL string) (err error)

func (*ClaDB) RemovePRsForUsers

func (p *ClaDB) RemovePRsForUsers(usersSigned []types.UserSignature, evalInfo *types.EvaluationInfo) (err error)

func (*ClaDB) StorePRAuthorsMissingSignature

func (p *ClaDB) StorePRAuthorsMissingSignature(evalInfo *types.EvaluationInfo, checkedAt time.Time) (err error)

type IClaDB

type IClaDB interface {
	InsertSignature(u *types.UserSignature) error
	HasAuthorSignedTheCla(login, claVersion string) (bool, *types.UserSignature, error)
	StorePRAuthorsMissingSignature(evalInfo *types.EvaluationInfo, checkedAt time.Time) error
	GetPRsForUser(*types.UserSignature) ([]types.EvaluationInfo, error)
	RemovePRsForUsers([]types.UserSignature, *types.EvaluationInfo) error
	MigrateDB(migrateSourceURL string) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL