(t *testing.T)
| 59 | } |
| 60 | |
| 61 | func TestWriteProtectionMechanism(t *testing.T) { |
| 62 | // Create a mock streamer |
| 63 | s := &Streamer{ |
| 64 | inode: 12345, |
| 65 | } |
| 66 | |
| 67 | // Create a mock handler |
| 68 | handler := &ExtentHandler{ |
| 69 | id: 1, |
| 70 | } |
| 71 | |
| 72 | // Test write protection |
| 73 | s.startWriteProtection(handler) |
| 74 | |
| 75 | // Verify handler is protected |
| 76 | if !s.isHandlerProtected(handler) { |
| 77 | t.Errorf("Handler should be protected after startWriteProtection") |
| 78 | } |
| 79 | |
| 80 | // Test with different handler |
| 81 | otherHandler := &ExtentHandler{ |
| 82 | id: 2, |
| 83 | } |
| 84 | if s.isHandlerProtected(otherHandler) { |
| 85 | t.Errorf("Other handler should not be protected") |
| 86 | } |
| 87 | |
| 88 | // End write protection |
| 89 | s.endWriteProtection() |
| 90 | |
| 91 | // Verify handler is no longer protected |
| 92 | if s.isHandlerProtected(handler) { |
| 93 | t.Errorf("Handler should not be protected after endWriteProtection") |
| 94 | } |
| 95 | |
| 96 | log.LogDebugf("Write protection test passed") |
| 97 | } |
nothing calls this directly
no test coverage detected