mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 22:23:50 +03:00
test(mock): DeletePushMirrors & AddPushMirrorRemote
make them into variables that can be mocked
(cherry picked from commit 5747951cc7
)
This commit is contained in:
parent
bcb473dd2a
commit
d900842fd7
2 changed files with 6 additions and 2 deletions
|
@ -94,7 +94,9 @@ func UpdatePushMirrorInterval(ctx context.Context, m *PushMirror) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeletePushMirrors(ctx context.Context, opts PushMirrorOptions) error {
|
var DeletePushMirrors = deletePushMirrors
|
||||||
|
|
||||||
|
func deletePushMirrors(ctx context.Context, opts PushMirrorOptions) error {
|
||||||
if opts.RepoID > 0 {
|
if opts.RepoID > 0 {
|
||||||
_, err := db.Delete[PushMirror](ctx, opts)
|
_, err := db.Delete[PushMirror](ctx, opts)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -28,7 +28,9 @@ import (
|
||||||
var stripExitStatus = regexp.MustCompile(`exit status \d+ - `)
|
var stripExitStatus = regexp.MustCompile(`exit status \d+ - `)
|
||||||
|
|
||||||
// AddPushMirrorRemote registers the push mirror remote.
|
// AddPushMirrorRemote registers the push mirror remote.
|
||||||
func AddPushMirrorRemote(ctx context.Context, m *repo_model.PushMirror, addr string) error {
|
var AddPushMirrorRemote = addPushMirrorRemote
|
||||||
|
|
||||||
|
func addPushMirrorRemote(ctx context.Context, m *repo_model.PushMirror, addr string) error {
|
||||||
addRemoteAndConfig := func(addr, path string) error {
|
addRemoteAndConfig := func(addr, path string) error {
|
||||||
cmd := git.NewCommand(ctx, "remote", "add", "--mirror=push").AddDynamicArguments(m.RemoteName, addr)
|
cmd := git.NewCommand(ctx, "remote", "add", "--mirror=push").AddDynamicArguments(m.RemoteName, addr)
|
||||||
if strings.Contains(addr, "://") && strings.Contains(addr, "@") {
|
if strings.Contains(addr, "://") && strings.Contains(addr, "@") {
|
||||||
|
|
Loading…
Reference in a new issue