mocks.go 620 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package database
  5. import (
  6. "testing"
  7. )
  8. func SetMockReposStore(t *testing.T, mock ReposStore) {
  9. before := Repos
  10. Repos = mock
  11. t.Cleanup(func() {
  12. Repos = before
  13. })
  14. }
  15. func SetMockTwoFactorsStore(t *testing.T, mock TwoFactorsStore) {
  16. before := TwoFactors
  17. TwoFactors = mock
  18. t.Cleanup(func() {
  19. TwoFactors = before
  20. })
  21. }
  22. func SetMockUsersStore(t *testing.T, mock UsersStore) {
  23. before := Users
  24. Users = mock
  25. t.Cleanup(func() {
  26. Users = before
  27. })
  28. }