(t *testing.T)
| 404 | } |
| 405 | |
| 406 | func TestWalBlockMetaSnapshot(t *testing.T) { |
| 407 | meta := backend.NewBlockMeta("fake", uuid.New(), VersionString) |
| 408 | w, err := createWALBlock(meta, t.TempDir(), model.CurrentEncoding, 0) |
| 409 | require.NoError(t, err) |
| 410 | |
| 411 | // Snapshot before any append: counts are zero, returned pointer is distinct. |
| 412 | snap0 := w.MetaSnapshot() |
| 413 | require.NotSame(t, w.BlockMeta(), snap0, "MetaSnapshot must return a fresh allocation, not the live meta pointer") |
| 414 | require.Equal(t, int64(0), snap0.TotalObjects) |
| 415 | |
| 416 | // Append a trace and confirm the snapshot reflects the mutation. |
| 417 | id := test.ValidTraceID(nil) |
| 418 | tr := test.MakeTrace(10, id) |
| 419 | trace.SortTrace(tr) |
| 420 | require.NoError(t, w.AppendTrace(id, tr, 100, 200, false)) |
| 421 | |
| 422 | snap1 := w.MetaSnapshot() |
| 423 | require.NotSame(t, snap0, snap1, "successive MetaSnapshot calls must return distinct pointers") |
| 424 | require.Equal(t, int64(1), snap1.TotalObjects) |
| 425 | require.Equal(t, w.BlockMeta().StartTime, snap1.StartTime) |
| 426 | require.Equal(t, w.BlockMeta().EndTime, snap1.EndTime) |
| 427 | |
| 428 | // Mutating the snapshot must not affect the live meta. |
| 429 | snap1.TotalObjects = 9999 |
| 430 | require.Equal(t, int64(1), w.BlockMeta().TotalObjects) |
| 431 | } |
| 432 | |
| 433 | func TestWalBlockTombstone(t *testing.T) { |
| 434 | meta := backend.NewBlockMeta("fake", uuid.New(), VersionString) |
nothing calls this directly
no test coverage detected