MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / TestHintEntryDecodeInvalidData

Function TestHintEntryDecodeInvalidData

hintfile_test.go:428–460  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

426}
427
428func TestHintEntryDecodeInvalidData(t *testing.T) {
429 testCases := []struct {
430 name string
431 data []byte
432 expectedErr error
433 }{
434 {
435 name: "Empty data",
436 data: []byte{},
437 expectedErr: ErrHintFileEntryInvalid,
438 },
439 {
440 name: "Incomplete header",
441 data: []byte{0x01}, // Only bucket ID, missing other fields
442 expectedErr: ErrHintFileCorrupted,
443 },
444 {
445 name: "Invalid varint",
446 data: []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, // Invalid varint
447 expectedErr: ErrHintFileCorrupted,
448 },
449 }
450
451 for _, tc := range testCases {
452 t.Run(tc.name, func(t *testing.T) {
453 entry := &HintEntry{}
454 err := entry.Decode(tc.data)
455 if err != tc.expectedErr {
456 t.Errorf("Expected error %v, got %v", tc.expectedErr, err)
457 }
458 })
459 }
460}
461
462func TestHintFilePartialRead(t *testing.T) {
463 tmpDir, err := os.MkdirTemp("", "hintfile-test")

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
RunMethod · 0.80

Tested by

no test coverage detected