Test closing repo without connect works (#5115)
Just make sure we can call Close() on the repository struct even if we have made a connection to kopia or initialized all the internal fields. --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
85aaa448c5
commit
e1cb5b6313
@ -36,6 +36,33 @@ func TestRepositoryUnitSuite(t *testing.T) {
|
|||||||
suite.Run(t, &RepositoryUnitSuite{Suite: tester.NewUnitSuite(t)})
|
suite.Run(t, &RepositoryUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestCloseWithoutConnectOrInit ensures SDK users can always call Close() on a
|
||||||
|
// Repositoryer handle without having to track if they called the Connect or
|
||||||
|
// Init functions. This makes cleanup easier for them because they can just use
|
||||||
|
// a defer Close() in some cases instead of having to track state.
|
||||||
|
func (suite *RepositoryUnitSuite) TestCloseWithoutConnectOrInit() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
ctx, flush := tester.NewContext(t)
|
||||||
|
t.Cleanup(flush)
|
||||||
|
|
||||||
|
acct := tconfig.NewFakeM365Account(t)
|
||||||
|
|
||||||
|
st, err := storage.NewStorage(storage.ProviderUnknown)
|
||||||
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
|
r, err := New(
|
||||||
|
ctx,
|
||||||
|
acct,
|
||||||
|
st,
|
||||||
|
control.DefaultOptions(),
|
||||||
|
NewRepoID)
|
||||||
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
|
err = r.Close(ctx)
|
||||||
|
assert.NoError(t, err, clues.ToCore(err))
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *RepositoryUnitSuite) TestInitialize() {
|
func (suite *RepositoryUnitSuite) TestInitialize() {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user