Fixed import log output duplicating

This commit is contained in:
Philipp Wolfer 2025-05-24 20:43:02 +02:00
parent b1b0df7763
commit 312d9860cf
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
4 changed files with 39 additions and 9 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>
Copyright © 2023-2025 Philipp Wolfer <phw@uploadedlobster.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -138,13 +138,31 @@ func TestImportResultUpdate(t *testing.T) {
LastTimestamp: time.Now().Add(1 * time.Hour),
ImportLog: []models.LogEntry{logEntry2},
}
result.Update(newResult)
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, []models.LogEntry{logEntry1, logEntry2}, result.ImportLog)
}
func TestImportResultCopy(t *testing.T) {
logEntry := models.LogEntry{
Type: models.Warning,
Message: "foo",
}
result := models.ImportResult{
TotalCount: 100,
ImportCount: 20,
LastTimestamp: time.Now(),
ImportLog: []models.LogEntry{logEntry},
}
copy := result.Copy()
assert.Equal(t, result.TotalCount, copy.TotalCount)
assert.Equal(t, result.ImportCount, copy.ImportCount)
assert.Equal(t, result.LastTimestamp, copy.LastTimestamp)
assert.Empty(t, copy.ImportLog)
}
func TestImportResultLog(t *testing.T) {
result := models.ImportResult{}
result.Log(models.Warning, "foo")