mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-02-23 03:45:47 -05:00
chore: Remove GetSourceByName
- Introduced in 5455605342
and removed in
the same commit. Usage was purely testing code.
This commit is contained in:
parent
1b10046e1a
commit
5423e22aeb
3 changed files with 2 additions and 18 deletions
|
@ -23,7 +23,6 @@ code.gitea.io/gitea/models/actions
|
||||||
ScheduleList.LoadRepos
|
ScheduleList.LoadRepos
|
||||||
|
|
||||||
code.gitea.io/gitea/models/auth
|
code.gitea.io/gitea/models/auth
|
||||||
GetSourceByName
|
|
||||||
WebAuthnCredentials
|
WebAuthnCredentials
|
||||||
|
|
||||||
code.gitea.io/gitea/models/db
|
code.gitea.io/gitea/models/db
|
||||||
|
|
|
@ -299,17 +299,6 @@ func GetSourceByID(ctx context.Context, id int64) (*Source, error) {
|
||||||
return source, nil
|
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.
|
// UpdateSource updates a Source record in DB.
|
||||||
func UpdateSource(ctx context.Context, source *Source) error {
|
func UpdateSource(ctx context.Context, source *Source) error {
|
||||||
var originalSource *Source
|
var originalSource *Source
|
||||||
|
|
|
@ -298,9 +298,7 @@ func addAuthSource(t *testing.T, payload map[string]string) *auth.Source {
|
||||||
payload["_csrf"] = GetCSRF(t, session, "/admin/auths/new")
|
payload["_csrf"] = GetCSRF(t, session, "/admin/auths/new")
|
||||||
req := NewRequestWithValues(t, "POST", "/admin/auths/new", payload)
|
req := NewRequestWithValues(t, "POST", "/admin/auths/new", payload)
|
||||||
session.MakeRequest(t, req, http.StatusSeeOther)
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
||||||
source, err := auth.GetSourceByName(context.Background(), payload["name"])
|
return unittest.AssertExistsAndLoadBean(t, &auth.Source{Name: payload["name"]})
|
||||||
require.NoError(t, err)
|
|
||||||
return source
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func authSourcePayloadOAuth2(name string) map[string]string {
|
func authSourcePayloadOAuth2(name string) map[string]string {
|
||||||
|
@ -358,9 +356,7 @@ func createRemoteAuthSource(t *testing.T, name, url, matchingSource string) *aut
|
||||||
MatchingSource: matchingSource,
|
MatchingSource: matchingSource,
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
source, err := auth.GetSourceByName(context.Background(), name)
|
return unittest.AssertExistsAndLoadBean(t, &auth.Source{Name: name})
|
||||||
require.NoError(t, err)
|
|
||||||
return source
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createUser(ctx context.Context, t testing.TB, user *user_model.User) func() {
|
func createUser(ctx context.Context, t testing.TB, user *user_model.User) func() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue