mocks.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 conf
  5. import (
  6. "testing"
  7. )
  8. func SetMockApp(t *testing.T, opts AppOpts) {
  9. before := App
  10. App = opts
  11. t.Cleanup(func() {
  12. App = before
  13. })
  14. }
  15. func SetMockAuth(t *testing.T, otps AuthOpts) {
  16. before := Auth
  17. Auth = otps
  18. t.Cleanup(func() {
  19. Auth = before
  20. })
  21. }
  22. func SetMockServer(t *testing.T, opts ServerOpts) {
  23. before := Server
  24. Server = opts
  25. t.Cleanup(func() {
  26. Server = before
  27. })
  28. }
  29. func SetMockSSH(t *testing.T, opts SSHOpts) {
  30. before := SSH
  31. SSH = opts
  32. t.Cleanup(func() {
  33. SSH = before
  34. })
  35. }
  36. func SetMockRepository(t *testing.T, opts RepositoryOpts) {
  37. before := Repository
  38. Repository = opts
  39. t.Cleanup(func() {
  40. Repository = before
  41. })
  42. }
  43. func SetMockUI(t *testing.T, opts UIOpts) {
  44. before := UI
  45. UI = opts
  46. t.Cleanup(func() {
  47. UI = before
  48. })
  49. }
  50. func SetMockPicture(t *testing.T, opts PictureOpts) {
  51. before := Picture
  52. Picture = opts
  53. t.Cleanup(func() {
  54. Picture = before
  55. })
  56. }