mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-29 08:29:23 +00:00
Merge pull request #100737 from Iceber/fix-delta-fifo
client-go/cache: fix the AddIfNotPresent method of the DeltaFIFO Kubernetes-commit: 1c9563d5d5e6345fc2f1a835b456a8ce916474bf
This commit is contained in:
commit
10997424fc
2
tools/cache/delta_fifo.go
vendored
2
tools/cache/delta_fifo.go
vendored
@ -340,7 +340,7 @@ func (f *DeltaFIFO) AddIfNotPresent(obj interface{}) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("object must be of type deltas, but got: %#v", obj)
|
||||
}
|
||||
id, err := f.KeyOf(deltas.Newest().Object)
|
||||
id, err := f.KeyOf(deltas)
|
||||
if err != nil {
|
||||
return KeyError{obj, err}
|
||||
}
|
||||
|
6
tools/cache/delta_fifo_test.go
vendored
6
tools/cache/delta_fifo_test.go
vendored
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package cache
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
@ -541,6 +542,11 @@ func TestDeltaFIFO_detectLineJumpers(t *testing.T) {
|
||||
func TestDeltaFIFO_addIfNotPresent(t *testing.T) {
|
||||
f := NewDeltaFIFOWithOptions(DeltaFIFOOptions{KeyFunction: testFifoObjectKeyFunc})
|
||||
|
||||
emptyDeltas := Deltas{}
|
||||
if err := f.AddIfNotPresent(emptyDeltas); err == nil || !errors.Is(err, ErrZeroLengthDeltasObject) {
|
||||
t.Errorf("Expected error '%v', got %v", ErrZeroLengthDeltasObject, err)
|
||||
}
|
||||
|
||||
f.Add(mkFifoObj("b", 3))
|
||||
b3 := Pop(f)
|
||||
f.Add(mkFifoObj("c", 4))
|
||||
|
Loading…
Reference in New Issue
Block a user