(t *testing.T)
| 236 | } |
| 237 | |
| 238 | func TestUpdateCompacted(t *testing.T) { |
| 239 | var ( |
| 240 | _1 = compactedMeta("00000000-0000-0000-0000-000000000001") |
| 241 | _2 = compactedMeta("00000000-0000-0000-0000-000000000002") |
| 242 | _3 = compactedMeta("00000000-0000-0000-0000-000000000003") |
| 243 | ) |
| 244 | |
| 245 | tests := []struct { |
| 246 | name string |
| 247 | existing []*backend.CompactedBlockMeta |
| 248 | add []*backend.CompactedBlockMeta |
| 249 | remove []*backend.CompactedBlockMeta |
| 250 | expected []*backend.CompactedBlockMeta |
| 251 | }{ |
| 252 | { |
| 253 | name: "all nil", |
| 254 | existing: nil, |
| 255 | add: nil, |
| 256 | expected: nil, |
| 257 | }, |
| 258 | { |
| 259 | name: "add to nil", |
| 260 | existing: nil, |
| 261 | add: []*backend.CompactedBlockMeta{_1}, |
| 262 | expected: []*backend.CompactedBlockMeta{_1}, |
| 263 | }, |
| 264 | { |
| 265 | name: "add to existing", |
| 266 | existing: []*backend.CompactedBlockMeta{_1}, |
| 267 | add: []*backend.CompactedBlockMeta{_2}, |
| 268 | expected: []*backend.CompactedBlockMeta{_1, _2}, |
| 269 | }, |
| 270 | { |
| 271 | name: "add already exists", |
| 272 | existing: []*backend.CompactedBlockMeta{_1}, |
| 273 | add: []*backend.CompactedBlockMeta{_1, _2}, |
| 274 | expected: []*backend.CompactedBlockMeta{_1, _2}, |
| 275 | }, |
| 276 | { |
| 277 | name: "add and remove", |
| 278 | existing: []*backend.CompactedBlockMeta{_1, _2}, |
| 279 | add: []*backend.CompactedBlockMeta{_3}, |
| 280 | remove: []*backend.CompactedBlockMeta{_2}, |
| 281 | expected: []*backend.CompactedBlockMeta{_1, _3}, |
| 282 | }, |
| 283 | { |
| 284 | name: "not added if also removed", |
| 285 | existing: []*backend.CompactedBlockMeta{_1}, |
| 286 | add: []*backend.CompactedBlockMeta{_2}, |
| 287 | remove: []*backend.CompactedBlockMeta{_2}, |
| 288 | expected: []*backend.CompactedBlockMeta{_1}, |
| 289 | }, |
| 290 | } |
| 291 | |
| 292 | for _, tt := range tests { |
| 293 | t.Run(tt.name, func(t *testing.T) { |
| 294 | l := New() |
| 295 |
nothing calls this directly
no test coverage detected