mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-22 16:45:43 +00:00
fix test error
This commit is contained in:
parent
d26118a515
commit
188bd054e5
1 changed files with 22 additions and 1 deletions
|
@ -8,14 +8,35 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// get the previous month from the current month, accounts for errors when run
|
||||
// near the beginning or end of the month/year
|
||||
func getPrevMonth(now time.Time) time.Time {
|
||||
t := now.AddDate(0, -1, 0)
|
||||
|
||||
// avoid infinite loop
|
||||
max := 15
|
||||
for t.Month() == now.Month() {
|
||||
println("month is the same")
|
||||
t = t.AddDate(0, 0, -1)
|
||||
println(t.String())
|
||||
|
||||
max--
|
||||
if max == 0 {
|
||||
panic("max exceeded")
|
||||
}
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func TestMaintenanceEntryRepository_GetLog(t *testing.T) {
|
||||
item := useItems(t, 1)[0]
|
||||
|
||||
// Create 10 maintenance entries for the item
|
||||
created := make([]MaintenanceEntryCreate, 10)
|
||||
|
||||
lastMonth := time.Now().AddDate(0, -1, 0)
|
||||
thisMonth := time.Now()
|
||||
lastMonth := getPrevMonth(thisMonth)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
dt := lastMonth
|
||||
|
|
Loading…
Reference in a new issue