checkForLeakedNoteboxes verifies no noteboxes remain open
(t *testing.T)
| 133 | |
| 134 | // checkForLeakedNoteboxes verifies no noteboxes remain open |
| 135 | func checkForLeakedNoteboxes(t *testing.T) { |
| 136 | count := 0 |
| 137 | openboxes.Range(func(key, value interface{}) bool { |
| 138 | count++ |
| 139 | if nbi, ok := value.(*NoteboxInstance); ok { |
| 140 | openfiles := 0 |
| 141 | nbi.openfiles.Range(func(k, v interface{}) bool { |
| 142 | if of, ok := v.(*OpenNotefile); ok { |
| 143 | if of.openCount > 0 { |
| 144 | openfiles++ |
| 145 | } |
| 146 | } |
| 147 | return true |
| 148 | }) |
| 149 | if openfiles > 0 { |
| 150 | t.Errorf("Leaked notebox: storage=%v, endpoint=%s, openfiles=%d", |
| 151 | key, nbi.endpointID, openfiles) |
| 152 | } |
| 153 | } |
| 154 | return true |
| 155 | }) |
| 156 | |
| 157 | if count > 0 { |
| 158 | t.Logf("Total noteboxes in cache: %d", count) |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // forceCleanupAllNoteboxes forcefully removes all noteboxes from the openboxes map |
| 163 | // This is used for test cleanup to ensure test isolation |
no outgoing calls
no test coverage detected