TestStore is a [Store] that can be used in tests.
| 80 | |
| 81 | // TestStore is a [Store] that can be used in tests. |
| 82 | type TestStore struct { |
| 83 | tb testenv.TB |
| 84 | |
| 85 | done chan struct{} |
| 86 | |
| 87 | storeLock sync.RWMutex // its RLock is exposed via [Store.Lock]/[Store.Unlock]. |
| 88 | storeLockCount atomic.Int32 |
| 89 | |
| 90 | mu sync.RWMutex |
| 91 | suspendCount int // change callback are suspended if > 0 |
| 92 | mr, mw map[pkey.Key]any // maps for reading and writing; they're the same unless the store is suspended. |
| 93 | cbs set.HandleSet[func()] |
| 94 | closed bool |
| 95 | |
| 96 | readsMu sync.Mutex |
| 97 | reads map[testReadOperation]int // how many times a policy setting was read |
| 98 | } |
| 99 | |
| 100 | // NewTestStore returns a new [TestStore]. |
| 101 | // The tb will be used to report coding errors detected by the [TestStore]. |
nothing calls this directly
no outgoing calls
no test coverage detected