mocks.go 818 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 SetMockServer(t *testing.T, opts ServerOpts) {
  16. before := Server
  17. Server = opts
  18. t.Cleanup(func() {
  19. Server = before
  20. })
  21. }
  22. func SetMockSSH(t *testing.T, opts SSHOpts) {
  23. before := SSH
  24. SSH = opts
  25. t.Cleanup(func() {
  26. SSH = before
  27. })
  28. }
  29. func SetMockRepository(t *testing.T, opts RepositoryOpts) {
  30. before := Repository
  31. Repository = opts
  32. t.Cleanup(func() {
  33. Repository = before
  34. })
  35. }
  36. func SetMockUI(t *testing.T, opts UIOpts) {
  37. before := UI
  38. UI = opts
  39. t.Cleanup(func() {
  40. UI = before
  41. })
  42. }