MCPcopy Create free account
hub / github.com/blues/note / checkForLeakedNoteboxes

Function checkForLeakedNoteboxes

lib/notebox_bug_demo_test.go:135–160  ·  view source on GitHub ↗

checkForLeakedNoteboxes verifies no noteboxes remain open

(t *testing.T)

Source from the content-addressed store, hash-verified

133
134// checkForLeakedNoteboxes verifies no noteboxes remain open
135func 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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected