1
0
Fork 0
forked from forgejo/forgejo

[TESTS] auth LinkAccount test coverage (squash)

(cherry picked from commit a2b2e3066b)
This commit is contained in:
Earl Warren 2023-06-27 11:50:09 +02:00
parent de2a6fe8c3
commit 841d1b5073
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 152 additions and 20 deletions

View file

@ -5,6 +5,7 @@
package auth
import (
"context"
"fmt"
"reflect"
@ -306,6 +307,17 @@ func GetSourceByID(id int64) (*Source, error) {
return source, nil
}
func GetSourceByName(ctx context.Context, name string) (*Source, error) {
source := &Source{}
has, err := db.GetEngine(ctx).Where("name = ?", name).Get(source)
if err != nil {
return nil, err
} else if !has {
return nil, ErrSourceNotExist{}
}
return source, nil
}
// UpdateSource updates a Source record in DB.
func UpdateSource(source *Source) error {
var originalSource *Source