mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-25 19:42:38 +00:00
[TESTS] auth LinkAccount test coverage
(cherry picked from commite11dcc60f2) use backticks to avoid backslash (cherry picked from commit34212791ee) (cherry picked from commitbde9473c69) (cherry picked from commitd4deb43084) (cherry picked from commit08e91649b0) (cherry picked from commit2b988e5415) [TESTS] auth LinkAccount test coverage (squash) (cherry picked from commita2b2e3066b) (cherry picked from commit841d1b5073) (cherry picked from commit35da630ad8)
This commit is contained in:
parent
16abc89780
commit
caf2dc4fa7
3 changed files with 195 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue