mirror of
https://git.sr.ht/~phw/scotty
synced 2025-07-01 07:41:57 +02:00
Replaced ImportResult.ImportErrors with ImportResult.ImportLog
This commit is contained in:
parent
91f9b62db3
commit
8a2ddb7772
5 changed files with 55 additions and 13 deletions
|
@ -117,23 +117,45 @@ func TestLovesListSort(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestImportResultUpdate(t *testing.T) {
|
||||
logEntry1 := models.LogEntry{
|
||||
Type: models.Warning,
|
||||
Message: "foo",
|
||||
}
|
||||
logEntry2 := models.LogEntry{
|
||||
Type: models.Error,
|
||||
Message: "bar",
|
||||
}
|
||||
result := models.ImportResult{
|
||||
TotalCount: 100,
|
||||
ImportCount: 20,
|
||||
LastTimestamp: time.Now(),
|
||||
ImportErrors: []string{"foo"},
|
||||
ImportLog: []models.LogEntry{logEntry1},
|
||||
}
|
||||
newResult := models.ImportResult{
|
||||
TotalCount: 120,
|
||||
ImportCount: 50,
|
||||
LastTimestamp: time.Now().Add(1 * time.Hour),
|
||||
ImportErrors: []string{"bar"},
|
||||
ImportLog: []models.LogEntry{logEntry2},
|
||||
}
|
||||
result.Update(newResult)
|
||||
assert.Equal(t, 120, result.TotalCount)
|
||||
assert.Equal(t, 50, result.ImportCount)
|
||||
assert.Equal(t, newResult.LastTimestamp, result.LastTimestamp)
|
||||
assert.Equal(t, []string{"foo", "bar"}, result.ImportErrors)
|
||||
assert.Equal(t, []models.LogEntry{logEntry1, logEntry2}, result.ImportLog)
|
||||
}
|
||||
|
||||
func TestImportResultLog(t *testing.T) {
|
||||
result := models.ImportResult{}
|
||||
result.Log(models.Warning, "foo")
|
||||
result.Log(models.Error, "bar")
|
||||
expected := []models.LogEntry{{
|
||||
Type: models.Warning,
|
||||
Message: "foo",
|
||||
}, {
|
||||
Type: models.Error,
|
||||
Message: "bar",
|
||||
}}
|
||||
assert.Equal(t, expected, result.ImportLog)
|
||||
}
|
||||
|
||||
func TestImportResultUpdateTimestamp(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue