Replaced ImportResult.ImportErrors with ImportResult.ImportLog

This commit is contained in:
Philipp Wolfer 2024-01-15 08:00:17 +01:00
parent 91f9b62db3
commit 8a2ddb7772
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
5 changed files with 55 additions and 13 deletions

View file

@ -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) {