Fix static tests

This commit is contained in:
2025-02-05 18:58:00 +00:00
parent 4a4b24fa45
commit 3d89a77565
4 changed files with 5 additions and 30 deletions
+1 -1
View File
@@ -48,6 +48,6 @@ func (b *BaseClient) decodeResponse(response []byte) (any, error) {
Message: "Can't decode response", Message: "Can't decode response",
Pairs: map[string]interface{}{"error": "unknown response type"}, Pairs: map[string]interface{}{"error": "unknown response type"},
}) })
return nil, fmt.Errorf("Can't decode response - unknown response type specified") return nil, fmt.Errorf("can't decode response - unknown response type specified")
} }
} }
+2 -2
View File
@@ -58,11 +58,11 @@ func Benchmark_NewLogger(b *testing.B) {
got := New() got := New()
if tt.triggers.ModFormat.Format != "" { if tt.triggers.ModFormat.Format != "" {
got = got.SetFormat(tt.triggers.ModFormat.Format) got.SetFormat(tt.triggers.ModFormat.Format)
} }
if tt.triggers.ModLevel.Level != 0 { if tt.triggers.ModLevel.Level != 0 {
got = got.SetMinLogLevel(tt.triggers.ModLevel.Level) got.SetMinLogLevel(tt.triggers.ModLevel.Level)
} }
} }
}) })
-25
View File
@@ -3,7 +3,6 @@ package libpack_logger
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"os"
"testing" "testing"
"time" "time"
@@ -11,30 +10,6 @@ import (
"github.com/goccy/go-reflect" "github.com/goccy/go-reflect"
) )
func captureStderr(f func()) string {
originalStderr := os.Stderr
r, w, _ := os.Pipe()
os.Stderr = w
f()
w.Close()
var buf bytes.Buffer
buf.ReadFrom(r)
os.Stderr = originalStderr
return buf.String()
}
func captureStdOut(f func()) string {
originalStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
f()
w.Close()
var buf bytes.Buffer
buf.ReadFrom(r)
os.Stdout = originalStdout
return buf.String()
}
func (suite *LoggerTestSuite) Test_LogMessageString() { func (suite *LoggerTestSuite) Test_LogMessageString() {
msg := &LogMessage{ msg := &LogMessage{
Message: "test message", Message: "test message",
+2 -2
View File
@@ -3,7 +3,7 @@ package gql
import ( import (
"encoding/json" "encoding/json"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
@@ -15,7 +15,7 @@ func StartMockServer() *httptest.Server {
// Create your handler // Create your handler
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Your existing handler code // Your existing handler code
bodyBytes, err := ioutil.ReadAll(r.Body) bodyBytes, err := io.ReadAll(r.Body)
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return