mirror of
https://github.com/hay-kot/homebox.git
synced 2025-06-16 08:52:34 +00:00
fix: inaccruate 401 & sql busy error (#679)
* fix inaccruate 401 error on SQL db error
* init golangci-lint config
* linter autofix
* testify auto fixes
* fix sqlite busy errors
* fix naming
* more linter errors
* fix rest of linter issues
Former-commit-id: e8449b3a73
This commit is contained in:
parent
5e83b28ff5
commit
03df23d97c
62 changed files with 389 additions and 292 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
"github.com/hay-kot/homebox/backend/internal/data/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// get the previous month from the current month, accounts for errors when run
|
||||
|
@ -67,7 +68,7 @@ func TestMaintenanceEntryRepository_GetLog(t *testing.T) {
|
|||
}
|
||||
|
||||
assert.Equal(t, item.ID, log.ItemID)
|
||||
assert.Equal(t, 10, len(log.Entries))
|
||||
assert.Len(t, log.Entries, 10)
|
||||
|
||||
// Calculate the average cost
|
||||
var total float64
|
||||
|
@ -76,11 +77,11 @@ func TestMaintenanceEntryRepository_GetLog(t *testing.T) {
|
|||
total += entry.Cost
|
||||
}
|
||||
|
||||
assert.Equal(t, total, log.CostTotal, "total cost should be equal to the sum of all entries")
|
||||
assert.Equal(t, total/2, log.CostAverage, "average cost should be the average of the two months")
|
||||
assert.InDelta(t, total, log.CostTotal, .001, "total cost should be equal to the sum of all entries")
|
||||
assert.InDelta(t, total/2, log.CostAverage, 001, "average cost should be the average of the two months")
|
||||
|
||||
for _, entry := range log.Entries {
|
||||
err := tRepos.MaintEntry.Delete(context.Background(), entry.ID)
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue