(t *testing.T)
| 27 | ) |
| 28 | |
| 29 | func TestTTLExpirationBasic(t *testing.T) { |
| 30 | testObj := testStoreObject{id: "foo", val: "bar"} |
| 31 | deleteChan := make(chan string, 1) |
| 32 | ttlStore := NewFakeExpirationStore( |
| 33 | testStoreKeyFunc, deleteChan, |
| 34 | &FakeExpirationPolicy{ |
| 35 | NeverExpire: sets.NewString(), |
| 36 | RetrieveKeyFunc: func(obj interface{}) (string, error) { |
| 37 | return obj.(*TimestampedEntry).Obj.(testStoreObject).id, nil |
| 38 | }, |
| 39 | }, |
| 40 | clock.RealClock{}, |
| 41 | ) |
| 42 | err := ttlStore.Add(testObj) |
| 43 | if err != nil { |
| 44 | t.Errorf("Unable to add obj %#v", testObj) |
| 45 | } |
| 46 | item, exists, err := ttlStore.Get(testObj) |
| 47 | if err != nil { |
| 48 | t.Errorf("Failed to get from store, %v", err) |
| 49 | } |
| 50 | if exists || item != nil { |
| 51 | t.Errorf("Got unexpected item %#v", item) |
| 52 | } |
| 53 | key, _ := testStoreKeyFunc(testObj) |
| 54 | select { |
| 55 | case delKey := <-deleteChan: |
| 56 | if delKey != key { |
| 57 | t.Errorf("Unexpected delete for key %s", key) |
| 58 | } |
| 59 | case <-time.After(wait.ForeverTestTimeout): |
| 60 | t.Errorf("Unexpected timeout waiting on delete") |
| 61 | } |
| 62 | close(deleteChan) |
| 63 | } |
| 64 | |
| 65 | func TestReAddExpiredItem(t *testing.T) { |
| 66 | deleteChan := make(chan string, 1) |
nothing calls this directly
no test coverage detected