fix(tests): use errors.Is() for error comparison and improve resource cleanup in analytics tests

Replace direct error equality check with errors.Is() in media_scanner_hash_test.

In analytics_test.go, improve defer patterns by capturing resp.Body as a named parameter
to avoid stale references, and add require.NoError() checks on all json.NewDecoder().Decode()
calls that were previously silently ignoring decode errors.
This commit is contained in:
2026-04-20 21:20:38 -04:00
parent 48725544f5
commit c1d3f1ae1d
2 changed files with 89 additions and 36 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"bufio"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"io"
"os"
@@ -73,7 +74,7 @@ func TestCalculateFileSHA256LargeFile(t *testing.T) {
buf := make([]byte, 4096)
for {
n, err := file.Read(buf)
if err != nil && err != bufio.ErrBufferFull {
if err != nil && !errors.Is(err, bufio.ErrBufferFull) {
if err == io.EOF {
break
}