MCPcopy Index your code
hub / github.com/coder/coder / AllAsserted

Method AllAsserted

coderd/coderdtest/authorize.go:181–195  ·  view source on GitHub ↗

AllAsserted returns an error if all calls to Authorize() have not been asserted and checked. This is useful for testing to ensure that all Authorize() calls are checked in the unit test.

()

Source from the content-addressed store, hash-verified

179// asserted and checked. This is useful for testing to ensure that all
180// Authorize() calls are checked in the unit test.
181func (r *RecordingAuthorizer) AllAsserted() error {
182 r.RLock()
183 defer r.RUnlock()
184 missed := []AuthCall{}
185 for _, c := range r.Called {
186 if !c.asserted {
187 missed = append(missed, c)
188 }
189 }
190
191 if len(missed) > 0 {
192 return xerrors.Errorf("missed calls: %+v", missed)
193 }
194 return nil
195}
196
197// AllCalls is useful for debugging.
198func (r *RecordingAuthorizer) AllCalls(actor *rbac.Subject) []AuthCall {

Callers 4

TestAuthzRecorderFunction · 0.95
TestCacheFunction · 0.95
SubtestWithDBMethod · 0.95
TestNewFunction · 0.80

Calls 1

ErrorfMethod · 0.45

Tested by 4

TestAuthzRecorderFunction · 0.76
TestCacheFunction · 0.76
SubtestWithDBMethod · 0.76
TestNewFunction · 0.64