(t *testing.T)
| 366 | } |
| 367 | |
| 368 | func TestIPList_GC(t *testing.T) { |
| 369 | var a = assert.NewAssertion(t) |
| 370 | |
| 371 | var list = iplibrary.NewIPList() |
| 372 | list.Add(&iplibrary.IPItem{ |
| 373 | Id: 1, |
| 374 | IPFrom: iputils.ToBytes("192.168.1.100"), |
| 375 | IPTo: iputils.ToBytes("192.168.1.101"), |
| 376 | ExpiredAt: time.Now().Unix() + 1, |
| 377 | }) |
| 378 | list.Add(&iplibrary.IPItem{ |
| 379 | Id: 2, |
| 380 | IPFrom: iputils.ToBytes("192.168.1.102"), |
| 381 | IPTo: iputils.ToBytes("192.168.1.103"), |
| 382 | ExpiredAt: 0, |
| 383 | }) |
| 384 | logs.PrintAsJSON(list.ItemsMap(), t) |
| 385 | logs.PrintAsJSON(list.AllItemsMap(), t) |
| 386 | |
| 387 | time.Sleep(3 * time.Second) |
| 388 | |
| 389 | t.Log("===AFTER GC===") |
| 390 | logs.PrintAsJSON(list.ItemsMap(), t) |
| 391 | logs.PrintAsJSON(list.SortedRangeItems(), t) |
| 392 | |
| 393 | a.IsTrue(len(list.ItemsMap()) == 1) |
| 394 | a.IsTrue(len(list.SortedRangeItems()) == 1) |
| 395 | } |
| 396 | |
| 397 | func TestManyLists(t *testing.T) { |
| 398 | debug.SetMaxThreads(20) |
nothing calls this directly
no test coverage detected