test(daemon): allocate unique helper row IDs
- commit
- 6c7d5d9a4e436c087a66ceace0f8a3aa158cec75
- author
- brice · · 2026-08-02 21:57 UTC
- committer
- brice · · 2026-08-03 17:54 UTC
- parent
- 7d1e3b2
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +14 -1
M internal/usecase/daemon/daemon_test.go +14 -1
| @@ -458,7 +458,20 @@ func testRow(text string) []renderer.Cell { | |||
| 458 | 458 | // wrapped out of. Tests that care about wrapped extents build the bound instead. | |
| 459 | 459 | func appendHistoryRow(tb testing.TB, history *vt.History, row []renderer.Cell) { | |
| 460 | 460 | tb.Helper() | |
| 461 | - | require.NoError(tb, history.AppendWithID(row, vt.LineBound{End: len(row)}, vt.RowID(1_000_000+history.Len()+1))) | |
| 461 | + | require.NoError(tb, history.Append(row, vt.LineBound{End: len(row)})) | |
| 462 | + | } | |
| 463 | + | ||
| 464 | + | func TestAppendHistoryRowAllocatesUniqueIDsAfterEviction(t *testing.T) { | |
| 465 | + | history := vt.NewHistory(vt.HistoryConfig{MaxRows: 2, ChunkRows: 1}) | |
| 466 | + | ids := make(map[vt.RowID]struct{}) | |
| 467 | + | for range 4 { | |
| 468 | + | appendHistoryRow(t, history, testRow("row")) | |
| 469 | + | view := history.View() | |
| 470 | + | id := view.RowID(view.Len() - 1) | |
| 471 | + | require.NotContains(t, ids, id) | |
| 472 | + | ids[id] = struct{}{} | |
| 473 | + | } | |
| 474 | + | require.Len(t, ids, 4) | |
| 462 | 475 | } | |
| 463 | 476 | ||
| 464 | 477 | func tabCount(sess *session) int { | |
| @@ -458,7 +458,20 @@ func testRow(text string) []renderer.Cell { | |||||
| 458 | // wrapped out of. Tests that care about wrapped extents build the bound instead. | 458 | // wrapped out of. Tests that care about wrapped extents build the bound instead. | ||
| 459 | func appendHistoryRow(tb testing.TB, history *vt.History, row []renderer.Cell) { | 459 | func appendHistoryRow(tb testing.TB, history *vt.History, row []renderer.Cell) { | ||
| 460 | tb.Helper() | 460 | tb.Helper() | ||
| 461 | - | require.NoError(tb, history.AppendWithID(row, vt.LineBound{End: len(row)}, vt.RowID(1_000_000+history.Len()+1))) | 461 | + | require.NoError(tb, history.Append(row, vt.LineBound{End: len(row)})) |
| 462 | + | } | |||
| 463 | + | ||||
| 464 | + | func TestAppendHistoryRowAllocatesUniqueIDsAfterEviction(t *testing.T) { | |||
| 465 | + | history := vt.NewHistory(vt.HistoryConfig{MaxRows: 2, ChunkRows: 1}) | |||
| 466 | + | ids := make(map[vt.RowID]struct{}) | |||
| 467 | + | for range 4 { | |||
| 468 | + | appendHistoryRow(t, history, testRow("row")) | |||
| 469 | + | view := history.View() | |||
| 470 | + | id := view.RowID(view.Len() - 1) | |||
| 471 | + | require.NotContains(t, ids, id) | |||
| 472 | + | ids[id] = struct{}{} | |||
| 473 | + | } | |||
| 474 | + | require.Len(t, ids, 4) | |||
| 462 | } | 475 | } | ||
| 463 | 476 | ||||
| 464 | func tabCount(sess *session) int { | 477 | func tabCount(sess *session) int { | ||