mirror of
https://git.sr.ht/~phw/scotty
synced 2025-06-05 04:58:33 +02:00
Fixed import log output duplicating
This commit is contained in:
parent
b1b0df7763
commit
312d9860cf
4 changed files with 39 additions and 9 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue