-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_test.go
More file actions
55 lines (44 loc) · 1.53 KB
/
app_test.go
File metadata and controls
55 lines (44 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestApp_Refresh_ResetsPerRunState(t *testing.T) {
t.Parallel()
ctx := NewLogger(false).WithContext(t.Context())
app := &App{
config: Config{},
offlineStrategy: &OfflineDatabaseStrategy{
Database: nil,
},
animeUpdater: newTestUpdater(),
mangaUpdater: newTestUpdater(),
reverseAnimeUpdater: newTestUpdater(),
reverseMangaUpdater: newTestUpdater(),
syncReport: NewSyncReport(),
}
// Simulate accumulated state from a previous run
app.animeUpdater.Statistics.UpdatedCount = 5
app.animeUpdater.UnmappedList = []UnmappedEntry{{Title: "test"}}
app.mangaUpdater.Statistics.SkippedCount = 3
app.reverseAnimeUpdater.Statistics.ErrorCount = 2
app.reverseMangaUpdater.UnmappedList = []UnmappedEntry{{Title: "test2"}}
app.syncReport.AddWarning("test", "warning", "detail", "anime")
app.Refresh(ctx)
// Statistics should be reset
assert.Equal(t, 0, app.animeUpdater.Statistics.UpdatedCount)
assert.Equal(t, 0, app.mangaUpdater.Statistics.SkippedCount)
assert.Equal(t, 0, app.reverseAnimeUpdater.Statistics.ErrorCount)
assert.Equal(t, 0, app.reverseMangaUpdater.Statistics.UpdatedCount)
// UnmappedList should be nil
assert.Nil(t, app.animeUpdater.UnmappedList)
assert.Nil(t, app.reverseMangaUpdater.UnmappedList)
// SyncReport should be fresh (no warnings)
assert.Empty(t, app.syncReport.Warnings)
}
func newTestUpdater() *Updater {
return &Updater{
Statistics: NewStatistics(),
StrategyChain: NewStrategyChain(),
}
}