mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move login related structs and functions to models/login (#17093)
* Move login related structs and functions to models/login * Fix test * Fix lint * Fix lint * Fix lint of windows * Fix lint * Fix test * Fix test * Only load necessary fixtures when preparing unit tests envs * Fix lint * Fix test * Fix test * Fix error log * Fix error log * Fix error log * remove unnecessary change * fix error log * merge main branch
This commit is contained in:
@@ -60,7 +60,7 @@ func TestRepository_GetWatchers(t *testing.T) {
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
||||
watchers, err := repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err := repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, repo.NumWatches)
|
||||
for _, watcher := range watchers {
|
||||
@@ -68,7 +68,7 @@ func TestRepository_GetWatchers(t *testing.T) {
|
||||
}
|
||||
|
||||
repo = db.AssertExistsAndLoadBean(t, &Repository{ID: 9}).(*Repository)
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, 0)
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func TestWatchIfAuto(t *testing.T) {
|
||||
assert.NoError(t, db.PrepareTestDatabase())
|
||||
|
||||
repo := db.AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
||||
watchers, err := repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err := repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, repo.NumWatches)
|
||||
|
||||
@@ -124,13 +124,13 @@ func TestWatchIfAuto(t *testing.T) {
|
||||
|
||||
// Must not add watch
|
||||
assert.NoError(t, WatchIfAuto(8, 1, true))
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, prevCount)
|
||||
|
||||
// Should not add watch
|
||||
assert.NoError(t, WatchIfAuto(10, 1, true))
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, prevCount)
|
||||
|
||||
@@ -138,31 +138,31 @@ func TestWatchIfAuto(t *testing.T) {
|
||||
|
||||
// Must not add watch
|
||||
assert.NoError(t, WatchIfAuto(8, 1, true))
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, prevCount)
|
||||
|
||||
// Should not add watch
|
||||
assert.NoError(t, WatchIfAuto(12, 1, false))
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, prevCount)
|
||||
|
||||
// Should add watch
|
||||
assert.NoError(t, WatchIfAuto(12, 1, true))
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, prevCount+1)
|
||||
|
||||
// Should remove watch, inhibit from adding auto
|
||||
assert.NoError(t, WatchRepo(12, 1, false))
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, prevCount)
|
||||
|
||||
// Must not add watch
|
||||
assert.NoError(t, WatchIfAuto(12, 1, true))
|
||||
watchers, err = repo.GetWatchers(ListOptions{Page: 1})
|
||||
watchers, err = repo.GetWatchers(db.ListOptions{Page: 1})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, watchers, prevCount)
|
||||
}
|
||||
|
Reference in New Issue
Block a user