MCPcopy
hub / github.com/kopia/kopia / MustReopen

Method MustReopen

internal/repotesting/repotesting.go:163–182  ·  view source on GitHub ↗

MustReopen closes and reopens the repository.

(tb testing.TB, openOpts ...func(*repo.Options))

Source from the content-addressed store, hash-verified

161
162// MustReopen closes and reopens the repository.
163func (e *Environment) MustReopen(tb testing.TB, openOpts ...func(*repo.Options)) {
164 tb.Helper()
165
166 ctx := testlogging.Context(tb)
167
168 err := e.RepositoryWriter.Close(ctx)
169 require.NoError(tb, err, "close error")
170
171 // ensure context passed to Open() is not used for cancellation signal.
172 ctx2, cancel := context.WithCancel(ctx)
173 defer cancel()
174
175 rep, err := repo.Open(ctx2, e.ConfigFile(), e.Password, repoOptions(openOpts))
176 require.NoError(tb, err)
177
178 tb.Cleanup(func() { rep.Close(ctx) })
179
180 _, e.RepositoryWriter, err = testutil.EnsureType[repo.DirectRepository](tb, rep).NewDirectWriter(ctx, repo.WriteSessionOptions{Purpose: "test"})
181 require.NoError(tb, err)
182}
183
184// MustOpenAnother opens another repository backed by the same storage location.
185func (e *Environment) MustOpenAnother(tb testing.TB, openOpts ...func(*repo.Options)) repo.RepositoryWriter {

Calls 9

ConfigFileMethod · 0.95
ContextFunction · 0.92
OpenFunction · 0.92
EnsureTypeFunction · 0.92
repoOptionsFunction · 0.85
HelperMethod · 0.80
CloseMethod · 0.65
CleanupMethod · 0.65
NewDirectWriterMethod · 0.65