Fix tests and improve comment on NewDeltaFIFO
This commit is contained in:
		@@ -28,13 +28,13 @@ import (
 | 
			
		||||
 | 
			
		||||
// NewDeltaFIFO returns a Queue which can be used to process changes to items.
 | 
			
		||||
//
 | 
			
		||||
// keyFunc is used to figure out what key an object should have. (It's
 | 
			
		||||
// keyFunc is used to figure out what key an object should have. (It is
 | 
			
		||||
// exposed in the returned DeltaFIFO's KeyOf() method, with bonus features.)
 | 
			
		||||
//
 | 
			
		||||
// 'keyLister' is expected to return a list of keys that the consumer of
 | 
			
		||||
// this queue "knows about". It is used to decide which items are missing
 | 
			
		||||
// when Replace() is called; 'Deleted' deltas are produced for these items.
 | 
			
		||||
// It may be nil if you don't need to detect all deletions.
 | 
			
		||||
// 'knownObjects' may be supplied to modify the behavior of Delete,
 | 
			
		||||
// Replace, and Resync.  It may be nil if you do not need those
 | 
			
		||||
// modifications.
 | 
			
		||||
//
 | 
			
		||||
// TODO: consider merging keyLister with this object, tracking a list of
 | 
			
		||||
//       "known" keys when Pop() is called. Have to think about how that
 | 
			
		||||
//       affects error retrying.
 | 
			
		||||
@@ -72,10 +72,10 @@ func NewDeltaFIFO(keyFunc KeyFunc, knownObjects KeyListerGetter) *DeltaFIFO {
 | 
			
		||||
// acumulator.  The accumulator associated with a given object's key
 | 
			
		||||
// is a Deltas, which is a slice of Delta values for that object.
 | 
			
		||||
// Applying an object to a Deltas means to append a Delta except when
 | 
			
		||||
// the potentially appended Delta is a Delete and the Deltas already
 | 
			
		||||
// ends with a Delete.  In that case the Deltas does not grow,
 | 
			
		||||
// although the terminal Delete will be replaced by the new Delete if
 | 
			
		||||
// the older Delete's object is a DeletedFinalStateUnknown.
 | 
			
		||||
// the potentially appended Delta is a Deleted and the Deltas already
 | 
			
		||||
// ends with a Deleted.  In that case the Deltas does not grow,
 | 
			
		||||
// although the terminal Deleted will be replaced by the new Deleted if
 | 
			
		||||
// the older Deleted's object is a DeletedFinalStateUnknown.
 | 
			
		||||
//
 | 
			
		||||
// DeltaFIFO is a producer-consumer queue, where a Reflector is
 | 
			
		||||
// intended to be the producer, and the consumer is whatever calls
 | 
			
		||||
 
 | 
			
		||||
@@ -347,7 +347,8 @@ func TestDeltaFIFO_ReplaceMakesDeletions(t *testing.T) {
 | 
			
		||||
	f.Replace([]interface{}{mkFifoObj("foo", 5)}, "0")
 | 
			
		||||
 | 
			
		||||
	expectedList = []Deltas{
 | 
			
		||||
		{{Deleted, DeletedFinalStateUnknown{Key: "baz", Obj: mkFifoObj("baz", 10)}}},
 | 
			
		||||
		{{Added, mkFifoObj("baz", 10)},
 | 
			
		||||
			{Deleted, DeletedFinalStateUnknown{Key: "baz", Obj: mkFifoObj("baz", 7)}}},
 | 
			
		||||
		{{Sync, mkFifoObj("foo", 5)}},
 | 
			
		||||
		// Since "bar" didn't have a delete event and wasn't in the Replace list
 | 
			
		||||
		// it should get a tombstone key with the right Obj.
 | 
			
		||||
@@ -370,7 +371,8 @@ func TestDeltaFIFO_ReplaceMakesDeletions(t *testing.T) {
 | 
			
		||||
	f.Replace([]interface{}{mkFifoObj("foo", 5)}, "0")
 | 
			
		||||
 | 
			
		||||
	expectedList = []Deltas{
 | 
			
		||||
		{{Deleted, DeletedFinalStateUnknown{Key: "baz", Obj: mkFifoObj("baz", 10)}}},
 | 
			
		||||
		{{Added, mkFifoObj("baz", 10)},
 | 
			
		||||
			{Deleted, DeletedFinalStateUnknown{Key: "baz", Obj: mkFifoObj("baz", 10)}}},
 | 
			
		||||
		{{Sync, mkFifoObj("foo", 5)}},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user