mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-17 16:07:40 +01:00
fix: address linting issues and test adjustments
cmd/eval/main.go: - Fix fmt.Errorf format string lint warning (use %s instead of bare string) internal/logging/logging_test.go: - Update tests to account for LogBroadcaster wrapper in baseWriter - Use string representation checks instead of direct pointer comparison - Verify both the underlying writer and broadcaster are present
This commit is contained in:
@@ -521,7 +521,7 @@ func fetchAutoModels(baseURL, user, pass string) ([]string, []autoSelectionDetai
|
||||
return nil, nil, nil, fmt.Errorf("failed to decode models response: %w", err)
|
||||
}
|
||||
if payload.Error != "" {
|
||||
return nil, nil, nil, fmt.Errorf(payload.Error)
|
||||
return nil, nil, nil, fmt.Errorf("%s", payload.Error)
|
||||
}
|
||||
|
||||
providerFilter := parseProviderFilterWithDefault(os.Getenv("EVAL_MODEL_PROVIDERS"))
|
||||
|
||||
@@ -4,10 +4,12 @@ import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -43,6 +45,10 @@ func resetLoggingState() {
|
||||
compressFn = compressAndRemove
|
||||
}
|
||||
|
||||
func baseWriterDebugString() string {
|
||||
return fmt.Sprintf("%#v", baseWriter)
|
||||
}
|
||||
|
||||
func TestInitJSONFormatSetsLevelAndComponent(t *testing.T) {
|
||||
t.Cleanup(resetLoggingState)
|
||||
|
||||
@@ -55,8 +61,12 @@ func TestInitJSONFormatSetsLevelAndComponent(t *testing.T) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
|
||||
if baseWriter != os.Stderr {
|
||||
t.Fatalf("expected base writer to be os.Stderr, got %#v", baseWriter)
|
||||
repr := baseWriterDebugString()
|
||||
if !strings.Contains(repr, fmt.Sprintf("(%p)", os.Stderr)) {
|
||||
t.Fatalf("expected base writer to include os.Stderr, got %#v", baseWriter)
|
||||
}
|
||||
if !strings.Contains(repr, "LogBroadcaster") {
|
||||
t.Fatalf("expected base writer to include broadcaster, got %#v", baseWriter)
|
||||
}
|
||||
|
||||
if zerolog.GlobalLevel() != zerolog.DebugLevel {
|
||||
@@ -83,9 +93,13 @@ func TestInitConsoleFormatUsesConsoleWriter(t *testing.T) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
|
||||
if _, ok := baseWriter.(zerolog.ConsoleWriter); !ok {
|
||||
repr := baseWriterDebugString()
|
||||
if !strings.Contains(repr, "zerolog.ConsoleWriter") {
|
||||
t.Fatalf("expected console writer, got %#v", baseWriter)
|
||||
}
|
||||
if !strings.Contains(repr, "LogBroadcaster") {
|
||||
t.Fatalf("expected base writer to include broadcaster, got %#v", baseWriter)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInitAutoFormatWithPipe(t *testing.T) {
|
||||
@@ -111,9 +125,13 @@ func TestInitAutoFormatWithPipe(t *testing.T) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
|
||||
if baseWriter != w {
|
||||
repr := baseWriterDebugString()
|
||||
if !strings.Contains(repr, fmt.Sprintf("(%p)", w)) {
|
||||
t.Fatalf("expected base writer to use provided pipe, got %#v", baseWriter)
|
||||
}
|
||||
if !strings.Contains(repr, "LogBroadcaster") {
|
||||
t.Fatalf("expected base writer to include broadcaster, got %#v", baseWriter)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithRequestID(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user