Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

repo_pushmirror_test.go 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2021 The Gitea 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 models
  5. import (
  6. "testing"
  7. "time"
  8. "code.gitea.io/gitea/modules/timeutil"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestPushMirrorsIterate(t *testing.T) {
  12. assert.NoError(t, PrepareTestDatabase())
  13. now := timeutil.TimeStampNow()
  14. InsertPushMirror(&PushMirror{
  15. RemoteName: "test-1",
  16. LastUpdateUnix: now,
  17. Interval: 1,
  18. })
  19. long, _ := time.ParseDuration("24h")
  20. InsertPushMirror(&PushMirror{
  21. RemoteName: "test-2",
  22. LastUpdateUnix: now,
  23. Interval: long,
  24. })
  25. InsertPushMirror(&PushMirror{
  26. RemoteName: "test-3",
  27. LastUpdateUnix: now,
  28. Interval: 0,
  29. })
  30. time.Sleep(1 * time.Millisecond)
  31. PushMirrorsIterate(func(idx int, bean interface{}) error {
  32. m, ok := bean.(*PushMirror)
  33. assert.True(t, ok)
  34. assert.Equal(t, "test-1", m.RemoteName)
  35. assert.Equal(t, m.RemoteName, m.GetRemoteName())
  36. return nil
  37. })
  38. }