(t *testing.T)
| 30 | } |
| 31 | |
| 32 | func TestBlockMetaObjectAdded(t *testing.T) { |
| 33 | now := time.Unix(time.Now().Unix(), 0) |
| 34 | |
| 35 | tests := []struct { |
| 36 | ids [][]byte |
| 37 | starts []uint32 |
| 38 | ends []uint32 |
| 39 | expectedStart time.Time |
| 40 | expectedEnd time.Time |
| 41 | expectedObjects int64 |
| 42 | }{ |
| 43 | {}, |
| 44 | { |
| 45 | ids: [][]byte{ |
| 46 | {0x01}, |
| 47 | }, |
| 48 | starts: []uint32{ |
| 49 | uint32(now.Unix()), |
| 50 | }, |
| 51 | ends: []uint32{ |
| 52 | uint32(now.Add(time.Minute).Unix()), |
| 53 | }, |
| 54 | expectedStart: now, |
| 55 | expectedEnd: now.Add(time.Minute), |
| 56 | expectedObjects: 1, |
| 57 | }, |
| 58 | { |
| 59 | ids: [][]byte{ |
| 60 | {0x01}, |
| 61 | {0x02}, |
| 62 | }, |
| 63 | starts: []uint32{ |
| 64 | uint32(now.Unix()), |
| 65 | uint32(now.Add(-time.Minute).Unix()), |
| 66 | }, |
| 67 | ends: []uint32{ |
| 68 | uint32(now.Add(time.Hour).Unix()), |
| 69 | uint32(now.Add(time.Minute).Unix()), |
| 70 | }, |
| 71 | expectedStart: now.Add(-time.Minute), |
| 72 | expectedEnd: now.Add(time.Hour), |
| 73 | expectedObjects: 2, |
| 74 | }, |
| 75 | } |
| 76 | |
| 77 | for _, tc := range tests { |
| 78 | b := &BlockMeta{} |
| 79 | |
| 80 | for i := 0; i < len(tc.ids); i++ { |
| 81 | b.ObjectAdded(tc.starts[i], tc.ends[i]) |
| 82 | } |
| 83 | |
| 84 | assert.Equal(t, tc.expectedStart, b.StartTime) |
| 85 | assert.Equal(t, tc.expectedEnd, b.EndTime) |
| 86 | assert.Equal(t, tc.expectedObjects, b.TotalObjects) |
| 87 | } |
| 88 | } |
| 89 |
nothing calls this directly
no test coverage detected