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

Function newMetricsCache

coderd/metricscache/metricscache_test.go:31–48  ·  view source on GitHub ↗
(t *testing.T, log slog.Logger, clock quartz.Clock, intervals metricscache.Intervals, usage bool)

Source from the content-addressed store, hash-verified

29}
30
31func newMetricsCache(t *testing.T, log slog.Logger, clock quartz.Clock, intervals metricscache.Intervals, usage bool) (*metricscache.Cache, database.Store) {
32 t.Helper()
33
34 accessControlStore := &atomic.Pointer[dbauthz.AccessControlStore]{}
35 var acs dbauthz.AccessControlStore = dbauthz.AGPLTemplateAccessControlStore{}
36 accessControlStore.Store(&acs)
37
38 var (
39 auth = rbac.NewStrictCachingAuthorizer(prometheus.NewRegistry())
40 db, _ = dbtestutil.NewDB(t)
41 dbauth = dbauthz.New(db, auth, log, accessControlStore)
42 cache = metricscache.New(dbauth, log, clock, intervals, usage)
43 )
44
45 t.Cleanup(func() { cache.Close() })
46
47 return cache, db
48}
49
50func TestCache_TemplateWorkspaceOwners(t *testing.T) {
51 t.Parallel()

Callers 3

TestCache_BuildTimeFunction · 0.85

Calls 8

NewDBFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
HelperMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
StoreMethod · 0.45

Tested by

no test coverage detected