mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(resp): keep the not-applied flag through redisStore under yaegi
Yaegi drops the flag when fmt.Errorf wraps the error, and it has no errors.As. respNotApplied now checks the top-level type only. The redisStore wrapper marks its own error when the pipeline error is marked.
This commit is contained in:
+15
-3
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRESPPipelineNotApplied(t *testing.T) {
|
||||
@@ -21,9 +22,6 @@ func TestRESPPipelineNotApplied(t *testing.T) {
|
||||
if !respNotApplied(err) {
|
||||
t.Errorf("respNotApplied(%v) = false, want true", err)
|
||||
}
|
||||
if !respNotApplied(fmt.Errorf("wrapped: %w", err)) {
|
||||
t.Error("respNotApplied lost the marker through fmt.Errorf %w")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("reply lost after bytes arrived is ambiguous", func(t *testing.T) {
|
||||
@@ -84,3 +82,17 @@ func TestRESPPipelineNotApplied(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestRedisStoreKeepsNotAppliedMarker(t *testing.T) {
|
||||
ln := newFakeListener(t)
|
||||
addr := ln.Addr().String()
|
||||
_ = ln.Close()
|
||||
s := newRedisStore(newRESPClient(addr, "", 0))
|
||||
entries := []counterIncr{{key: "k", delta: 1, ttl: time.Minute, enforceTTL: time.Minute}}
|
||||
if _, err := s.incrMulti(entries); err == nil || !respNotApplied(err) {
|
||||
t.Errorf("incrMulti error %v: respNotApplied = false, want true for a dial failure", err)
|
||||
}
|
||||
if _, _, err := s.incrAndGetMulti(entries, nil); err == nil || !respNotApplied(err) {
|
||||
t.Errorf("incrAndGetMulti error %v: respNotApplied = false, want true for a dial failure", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user