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