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

Function TestHintFileWriterErrorHandling

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

Source from the content-addressed store, hash-verified

314}
315
316func TestHintFileWriterErrorHandling(t *testing.T) {
317 t.Run("Write nil entry", func(t *testing.T) {
318 writer := &HintFileWriter{}
319 err := writer.Write(nil)
320 if err != ErrHintFileEntryInvalid {
321 t.Errorf("Expected ErrHintFileEntryInvalid, got %v", err)
322 }
323 })
324
325 t.Run("Create file in non-existent directory", func(t *testing.T) {
326 writer := &HintFileWriter{}
327 writerPath := filepath.Join("non", "existent", "path", "test.hint")
328 err := writer.Create(writerPath)
329 if err == nil {
330 t.Error("Expected error when creating file in non-existent directory")
331 }
332 })
333
334 t.Run("Sync without file", func(t *testing.T) {
335 writer := &HintFileWriter{}
336 err := writer.Sync()
337 if err != nil {
338 t.Errorf("Unexpected error when syncing without file: %v", err)
339 }
340 })
341
342 t.Run("Close without file", func(t *testing.T) {
343 writer := &HintFileWriter{}
344 err := writer.Close()
345 if err != nil {
346 t.Errorf("Unexpected error when closing without file: %v", err)
347 }
348 })
349}
350
351func TestHintFileReaderErrorHandling(t *testing.T) {
352 t.Run("Open non-existent file", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

WriteMethod · 0.95
CreateMethod · 0.95
SyncMethod · 0.95
CloseMethod · 0.95
RunMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected