MCPcopy
hub / github.com/prometheus/prometheus / newTestDB

Function newTestDB

tsdb/db_test.go:109–132  ·  view source on GitHub ↗
(t testing.TB, opts ...testDBOpt)

Source from the content-addressed store, hash-verified

107}
108
109func newTestDB(t testing.TB, opts ...testDBOpt) (db *DB) {
110 var o testDBOptions
111 for _, opt := range opts {
112 opt(&o)
113 }
114 if o.opts == nil {
115 o.opts = DefaultOptions()
116 }
117 if o.dir == "" {
118 o.dir = t.TempDir()
119 }
120
121 var err error
122 o.opts, o.rngs, err = validateOpts(o.opts, o.rngs)
123 require.NoError(t, err)
124 db, err = open(o.dir, nil, nil, o.opts, o.rngs, nil)
125 require.NoError(t, err)
126
127 t.Cleanup(func() {
128 // Always close. DB is safe for close-after-close.
129 require.NoError(t, db.Close())
130 })
131 return db
132}
133
134func TestDBClose_AfterClose(t *testing.T) {
135 db := newTestDB(t)

Calls 4

validateOptsFunction · 0.85
openFunction · 0.85
DefaultOptionsFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…