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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user