2022-06-12 10:34:12 +08:00
|
|
|
// Copyright 2020 The Gogs Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
2020-04-06 18:35:10 +08:00
|
|
|
|
2024-02-18 19:39:41 -05:00
|
|
|
package database
|
2020-04-06 18:35:10 +08:00
|
|
|
|
|
|
|
|
import (
|
2022-06-12 10:34:12 +08:00
|
|
|
"testing"
|
2020-04-06 18:35:10 +08:00
|
|
|
)
|
|
|
|
|
|
2022-06-12 10:34:12 +08:00
|
|
|
func SetMockPermsStore(t *testing.T, mock PermsStore) {
|
|
|
|
|
before := Perms
|
|
|
|
|
Perms = mock
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
|
Perms = before
|
2022-06-10 11:27:06 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-12 10:34:12 +08:00
|
|
|
func SetMockReposStore(t *testing.T, mock ReposStore) {
|
|
|
|
|
before := Repos
|
|
|
|
|
Repos = mock
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
|
Repos = before
|
2022-06-10 11:27:06 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-12 10:34:12 +08:00
|
|
|
func SetMockTwoFactorsStore(t *testing.T, mock TwoFactorsStore) {
|
|
|
|
|
before := TwoFactors
|
|
|
|
|
TwoFactors = mock
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
|
TwoFactors = before
|
2022-06-08 19:26:20 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-12 10:34:12 +08:00
|
|
|
func SetMockUsersStore(t *testing.T, mock UsersStore) {
|
|
|
|
|
before := Users
|
|
|
|
|
Users = mock
|
|
|
|
|
t.Cleanup(func() {
|
|
|
|
|
Users = before
|
2022-06-08 19:26:20 +08:00
|
|
|
})
|
|
|
|
|
}
|