chore: update golangci-lint to v2.12.2 with canonical config
All checks were successful
check / check (push) Successful in 2m3s
All checks were successful
check / check (push) Successful in 2m3s
Replace .golangci.yml with the canonical v2-schema config (default: all minus six disabled linters, lll 88, tests included) and bump every golangci-lint pin to v2.12.2: - Dockerfile: golangci/golangci-lint:v2.12.2-alpine (hash-pinned) - script/bootstrap: GOLANGCI_LINT_VERSION 2.12.2 with new linux-amd64/arm64 release-archive sha256 pins Fix all 747 findings the stricter config surfaces, with no behavior changes: t.Parallel() throughout the test suite, static sentinel errors and errors.Is comparisons, checked error returns, context propagation (contextcheck/noctx), 88-column wrapping, extracted constants and helpers for goconst/dupl/funlen/cyclop, exhaustive switch cases replicating existing defaults, and white-box test files renamed to *_internal_test.go for testpackage. Three nolint:tagliatelle directives preserve the existing snake_case JSON wire and on-disk metadata formats.
This commit is contained in:
47
internal/imgcache/divzero_internal_test.go
Normal file
47
internal/imgcache/divzero_internal_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package imgcache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSizePercentSafeWithZeroFetchBytes(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Simulate the calculation from processAndStore
|
||||
fetchBytes := int64(0)
|
||||
outputSize := int64(100)
|
||||
|
||||
var sizePercent float64
|
||||
if fetchBytes > 0 {
|
||||
sizePercent = float64(outputSize) / float64(fetchBytes) * 100.0
|
||||
}
|
||||
|
||||
// sizePercent should be 0, not Inf or NaN
|
||||
if math.IsInf(sizePercent, 0) || math.IsNaN(sizePercent) {
|
||||
t.Errorf("sizePercent = %f, should not be Inf/NaN", sizePercent)
|
||||
}
|
||||
|
||||
// Should produce valid log output
|
||||
result := fmt.Sprintf("%.1f%%", sizePercent)
|
||||
if result != "0.0%" {
|
||||
t.Errorf("formatted size ratio = %q, want %q", result, "0.0%")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSizePercentNormalCase(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
fetchBytes := int64(1000)
|
||||
outputSize := int64(500)
|
||||
|
||||
var sizePercent float64
|
||||
if fetchBytes > 0 {
|
||||
sizePercent = float64(outputSize) / float64(fetchBytes) * 100.0
|
||||
}
|
||||
|
||||
if math.Abs(sizePercent-50.0) > 0.001 {
|
||||
t.Errorf("sizePercent = %f, want 50.0", sizePercent)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user