Update tests in kopia package (#2514)
## Description Use the new suite.Suite wrappers in tester package. Also update suite.Run and some nolint directives. ## 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] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup ## Issue(s) * #2373 ## Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
034ee0df39
commit
476a931ccb
@ -33,11 +33,11 @@ func openKopiaRepo(t *testing.T, ctx context.Context) (*conn, error) {
|
|||||||
// unit tests
|
// unit tests
|
||||||
// ---------------
|
// ---------------
|
||||||
type WrapperUnitSuite struct {
|
type WrapperUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrapperUnitSuite(t *testing.T) {
|
func TestWrapperUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(WrapperUnitSuite))
|
suite.Run(t, &WrapperUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *WrapperUnitSuite) TestCloseWithoutOpenDoesNotCrash() {
|
func (suite *WrapperUnitSuite) TestCloseWithoutOpenDoesNotCrash() {
|
||||||
@ -55,20 +55,17 @@ func (suite *WrapperUnitSuite) TestCloseWithoutOpenDoesNotCrash() {
|
|||||||
// integration tests that use kopia
|
// integration tests that use kopia
|
||||||
// ---------------
|
// ---------------
|
||||||
type WrapperIntegrationSuite struct {
|
type WrapperIntegrationSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWrapperIntegrationSuite(t *testing.T) {
|
func TestWrapperIntegrationSuite(t *testing.T) {
|
||||||
tester.RunOnAny(
|
suite.Run(t, &WrapperIntegrationSuite{
|
||||||
t,
|
Suite: tester.NewIntegrationSuite(
|
||||||
tester.CorsoCITests,
|
t,
|
||||||
tester.CorsoKopiaWrapperTests)
|
[][]string{tester.AWSStorageCredEnvs},
|
||||||
|
tester.CorsoKopiaWrapperTests,
|
||||||
suite.Run(t, new(WrapperIntegrationSuite))
|
),
|
||||||
}
|
})
|
||||||
|
|
||||||
func (suite *WrapperIntegrationSuite) SetupSuite() {
|
|
||||||
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *WrapperIntegrationSuite) TestRepoExistsError() {
|
func (suite *WrapperIntegrationSuite) TestRepoExistsError() {
|
||||||
@ -296,10 +293,12 @@ func (suite *WrapperIntegrationSuite) TestConfigDefaultsSetOnInitAndConnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
k, err := openKopiaRepo(t, ctx)
|
k, err := openKopiaRepo(t, ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|||||||
@ -23,11 +23,11 @@ import (
|
|||||||
// unit tests
|
// unit tests
|
||||||
// ---------------
|
// ---------------
|
||||||
type KopiaDataCollectionUnitSuite struct {
|
type KopiaDataCollectionUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKopiaDataCollectionUnitSuite(t *testing.T) {
|
func TestKopiaDataCollectionUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(KopiaDataCollectionUnitSuite))
|
suite.Run(t, &KopiaDataCollectionUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KopiaDataCollectionUnitSuite) TestReturnsPath() {
|
func (suite *KopiaDataCollectionUnitSuite) TestReturnsPath() {
|
||||||
@ -93,7 +93,9 @@ func (suite *KopiaDataCollectionUnitSuite) TestReturnsStreams() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
c := kopiaDataCollection{
|
c := kopiaDataCollection{
|
||||||
streams: test.streams,
|
streams: test.streams,
|
||||||
path: nil,
|
path: nil,
|
||||||
|
|||||||
@ -23,9 +23,8 @@ type fooModel struct {
|
|||||||
Bar string
|
Bar string
|
||||||
}
|
}
|
||||||
|
|
||||||
//revive:disable:context-as-argument
|
//revive:disable-next-line:context-as-argument
|
||||||
func getModelStore(t *testing.T, ctx context.Context) *ModelStore {
|
func getModelStore(t *testing.T, ctx context.Context) *ModelStore {
|
||||||
//revive:enable:context-as-argument
|
|
||||||
c, err := openKopiaRepo(t, ctx)
|
c, err := openKopiaRepo(t, ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -36,11 +35,11 @@ func getModelStore(t *testing.T, ctx context.Context) *ModelStore {
|
|||||||
// unit tests
|
// unit tests
|
||||||
// ---------------
|
// ---------------
|
||||||
type ModelStoreUnitSuite struct {
|
type ModelStoreUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestModelStoreUnitSuite(t *testing.T) {
|
func TestModelStoreUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(ModelStoreUnitSuite))
|
suite.Run(t, &ModelStoreUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ModelStoreUnitSuite) TestCloseWithoutInitDoesNotPanic() {
|
func (suite *ModelStoreUnitSuite) TestCloseWithoutInitDoesNotPanic() {
|
||||||
@ -57,23 +56,20 @@ func (suite *ModelStoreUnitSuite) TestCloseWithoutInitDoesNotPanic() {
|
|||||||
// integration tests that use kopia
|
// integration tests that use kopia
|
||||||
// ---------------
|
// ---------------
|
||||||
type ModelStoreIntegrationSuite struct {
|
type ModelStoreIntegrationSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
m *ModelStore
|
m *ModelStore
|
||||||
flush func()
|
flush func()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestModelStoreIntegrationSuite(t *testing.T) {
|
func TestModelStoreIntegrationSuite(t *testing.T) {
|
||||||
tester.RunOnAny(
|
suite.Run(t, &ModelStoreIntegrationSuite{
|
||||||
t,
|
Suite: tester.NewIntegrationSuite(
|
||||||
tester.CorsoCITests,
|
t,
|
||||||
tester.CorsoModelStoreTests)
|
[][]string{tester.AWSStorageCredEnvs},
|
||||||
|
tester.CorsoModelStoreTests,
|
||||||
suite.Run(t, new(ModelStoreIntegrationSuite))
|
),
|
||||||
}
|
})
|
||||||
|
|
||||||
func (suite *ModelStoreIntegrationSuite) SetupSuite() {
|
|
||||||
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ModelStoreIntegrationSuite) SetupTest() {
|
func (suite *ModelStoreIntegrationSuite) SetupTest() {
|
||||||
@ -112,7 +108,9 @@ func (suite *ModelStoreIntegrationSuite) TestBadTagsErrors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
foo := &fooModel{Bar: uuid.NewString()}
|
foo := &fooModel{Bar: uuid.NewString()}
|
||||||
foo.Tags = test.tags
|
foo.Tags = test.tags
|
||||||
|
|
||||||
@ -258,7 +256,9 @@ func (suite *ModelStoreIntegrationSuite) TestPutGet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.s.String(), func(t *testing.T) {
|
suite.Run(test.s.String(), func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
foo := &fooModel{Bar: uuid.NewString()}
|
foo := &fooModel{Bar: uuid.NewString()}
|
||||||
// Avoid some silly test errors from comparing nil to empty map.
|
// Avoid some silly test errors from comparing nil to empty map.
|
||||||
foo.Tags = map[string]string{}
|
foo.Tags = map[string]string{}
|
||||||
@ -306,7 +306,9 @@ func (suite *ModelStoreIntegrationSuite) TestPutGet_PreSetID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
foo := &fooModel{
|
foo := &fooModel{
|
||||||
BaseModel: model.BaseModel{ID: model.StableID(test.baseID)},
|
BaseModel: model.BaseModel{ID: model.StableID(test.baseID)},
|
||||||
Bar: uuid.NewString(),
|
Bar: uuid.NewString(),
|
||||||
@ -411,7 +413,9 @@ func (suite *ModelStoreIntegrationSuite) TestPutGetOfType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.s.String(), func(t *testing.T) {
|
suite.Run(test.s.String(), func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
foo := &fooModel{Bar: uuid.NewString()}
|
foo := &fooModel{Bar: uuid.NewString()}
|
||||||
|
|
||||||
err := suite.m.Put(suite.ctx, test.s, foo)
|
err := suite.m.Put(suite.ctx, test.s, foo)
|
||||||
@ -546,7 +550,9 @@ func (suite *ModelStoreIntegrationSuite) TestGetOfTypeWithTags() {
|
|||||||
|
|
||||||
// Check we can properly execute our tests.
|
// Check we can properly execute our tests.
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
expected := make([]*model.BaseModel, 0, len(test.expectedModels))
|
expected := make([]*model.BaseModel, 0, len(test.expectedModels))
|
||||||
for _, e := range test.expectedModels {
|
for _, e := range test.expectedModels {
|
||||||
expected = append(expected, &e.BaseModel)
|
expected = append(expected, &e.BaseModel)
|
||||||
@ -585,7 +591,9 @@ func (suite *ModelStoreIntegrationSuite) TestPutUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
@ -660,7 +668,9 @@ func (suite *ModelStoreIntegrationSuite) TestPutUpdate_FailsNotMatchingPrev() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
@ -706,20 +716,17 @@ func (suite *ModelStoreIntegrationSuite) TestPutDelete_BadIDsNoop() {
|
|||||||
// regression tests that use kopia
|
// regression tests that use kopia
|
||||||
// ---------------
|
// ---------------
|
||||||
type ModelStoreRegressionSuite struct {
|
type ModelStoreRegressionSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestModelStoreRegressionSuite(t *testing.T) {
|
func TestModelStoreRegressionSuite(t *testing.T) {
|
||||||
tester.RunOnAny(
|
suite.Run(t, &ModelStoreRegressionSuite{
|
||||||
t,
|
Suite: tester.NewIntegrationSuite(
|
||||||
tester.CorsoCITests,
|
t,
|
||||||
tester.CorsoModelStoreTests)
|
[][]string{tester.AWSStorageCredEnvs},
|
||||||
|
tester.CorsoModelStoreTests,
|
||||||
suite.Run(t, new(ModelStoreRegressionSuite))
|
),
|
||||||
}
|
})
|
||||||
|
|
||||||
func (suite *ModelStoreRegressionSuite) SetupSuite() {
|
|
||||||
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ashmrtn): Make a mock of whatever controls the handle to kopia so we can
|
// TODO(ashmrtn): Make a mock of whatever controls the handle to kopia so we can
|
||||||
@ -784,12 +791,10 @@ func (suite *ModelStoreRegressionSuite) TestFailDuringWriteSessionHasNoVisibleEf
|
|||||||
assert.Equal(t, foo, returned)
|
assert.Equal(t, foo, returned)
|
||||||
}
|
}
|
||||||
|
|
||||||
//revive:disable:context-as-argument
|
|
||||||
func openConnAndModelStore(
|
func openConnAndModelStore(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
ctx context.Context,
|
ctx context.Context, //revive:disable-line:context-as-argument
|
||||||
) (*conn, *ModelStore) {
|
) (*conn, *ModelStore) {
|
||||||
//revive:enable:context-as-argument
|
|
||||||
st := tester.NewPrefixedS3Storage(t)
|
st := tester.NewPrefixedS3Storage(t)
|
||||||
c := NewConn(st)
|
c := NewConn(st)
|
||||||
|
|
||||||
@ -805,13 +810,11 @@ func openConnAndModelStore(
|
|||||||
return c, ms
|
return c, ms
|
||||||
}
|
}
|
||||||
|
|
||||||
//revive:disable:context-as-argument
|
|
||||||
func reconnectToModelStore(
|
func reconnectToModelStore(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
ctx context.Context,
|
ctx context.Context, //revive:disable-line:context-as-argument
|
||||||
c *conn,
|
c *conn,
|
||||||
) *ModelStore {
|
) *ModelStore {
|
||||||
//revive:enable:context-as-argument
|
|
||||||
require.NoError(t, c.Connect(ctx))
|
require.NoError(t, c.Connect(ctx))
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
@ -7,14 +7,16 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PathEncoderSuite struct {
|
type PathEncoderSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPathEncoderSuite(t *testing.T) {
|
func TestPathEncoderSuite(t *testing.T) {
|
||||||
suite.Run(t, new(PathEncoderSuite))
|
suite.Run(t, &PathEncoderSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *PathEncoderSuite) TestEncodeDecode() {
|
func (suite *PathEncoderSuite) TestEncodeDecode() {
|
||||||
@ -66,7 +68,9 @@ func (suite *PathEncoderSuite) TestEncodeAsPathDecode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
encoded := encodeAsPath(test.elements...)
|
encoded := encodeAsPath(test.elements...)
|
||||||
|
|
||||||
// Sanity check, first and last character should not be '/'.
|
// Sanity check, first and last character should not be '/'.
|
||||||
|
|||||||
@ -187,11 +187,11 @@ func (msm *mockSnapshotManager) LoadSnapshots(
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SnapshotFetchUnitSuite struct {
|
type SnapshotFetchUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSnapshotFetchUnitSuite(t *testing.T) {
|
func TestSnapshotFetchUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(SnapshotFetchUnitSuite))
|
suite.Run(t, &SnapshotFetchUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *SnapshotFetchUnitSuite) TestFetchPrevSnapshots() {
|
func (suite *SnapshotFetchUnitSuite) TestFetchPrevSnapshots() {
|
||||||
@ -752,7 +752,9 @@ func (suite *SnapshotFetchUnitSuite) TestFetchPrevSnapshots() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
@ -874,7 +876,9 @@ func (suite *SnapshotFetchUnitSuite) TestFetchPrevSnapshots_customTags() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
|
|||||||
@ -93,15 +93,12 @@ func expectedTreeWithChildren(
|
|||||||
|
|
||||||
// Currently only works for files that Corso has serialized as it expects a
|
// Currently only works for files that Corso has serialized as it expects a
|
||||||
// version specifier at the start of the file.
|
// version specifier at the start of the file.
|
||||||
//
|
|
||||||
//revive:disable:context-as-argument
|
|
||||||
func expectFileData(
|
func expectFileData(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
ctx context.Context,
|
ctx context.Context, //revive:disable-line:context-as-argument
|
||||||
expected []byte,
|
expected []byte,
|
||||||
f fs.StreamingFile,
|
f fs.StreamingFile,
|
||||||
) {
|
) {
|
||||||
//revive:enable:context-as-argument
|
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
if len(expected) == 0 {
|
if len(expected) == 0 {
|
||||||
@ -132,14 +129,12 @@ func expectFileData(
|
|||||||
assert.Equalf(t, expected, got, "data in file: %s", name)
|
assert.Equalf(t, expected, got, "data in file: %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
//revive:disable:context-as-argument
|
|
||||||
func expectTree(
|
func expectTree(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
ctx context.Context,
|
ctx context.Context, //revive:disable-line:context-as-argument
|
||||||
expected *expectedNode,
|
expected *expectedNode,
|
||||||
got fs.Entry,
|
got fs.Entry,
|
||||||
) {
|
) {
|
||||||
//revive:enable:context-as-argument
|
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
if expected == nil {
|
if expected == nil {
|
||||||
@ -199,13 +194,11 @@ func expectDirs(
|
|||||||
assert.Subset(t, names, dirs)
|
assert.Subset(t, names, dirs)
|
||||||
}
|
}
|
||||||
|
|
||||||
//revive:disable:context-as-argument
|
|
||||||
func getDirEntriesForEntry(
|
func getDirEntriesForEntry(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
ctx context.Context,
|
ctx context.Context, //revive:disable-line:context-as-argument
|
||||||
entry fs.Entry,
|
entry fs.Entry,
|
||||||
) []fs.Entry {
|
) []fs.Entry {
|
||||||
//revive:enable:context-as-argument
|
|
||||||
d, ok := entry.(fs.Directory)
|
d, ok := entry.(fs.Directory)
|
||||||
require.True(t, ok, "entry is not a directory")
|
require.True(t, ok, "entry is not a directory")
|
||||||
|
|
||||||
@ -238,11 +231,11 @@ func (lrr *limitedRangeReader) Read(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type VersionReadersUnitSuite struct {
|
type VersionReadersUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVersionReadersUnitSuite(t *testing.T) {
|
func TestVersionReadersUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(VersionReadersUnitSuite))
|
suite.Run(t, &VersionReadersUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *VersionReadersUnitSuite) TestWriteAndRead() {
|
func (suite *VersionReadersUnitSuite) TestWriteAndRead() {
|
||||||
@ -268,7 +261,9 @@ func (suite *VersionReadersUnitSuite) TestWriteAndRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
baseReader := bytes.NewReader(inputData)
|
baseReader := bytes.NewReader(inputData)
|
||||||
|
|
||||||
reversible := &restoreStreamReader{
|
reversible := &restoreStreamReader{
|
||||||
@ -347,13 +342,13 @@ func (suite *VersionReadersUnitSuite) TestWriteHandlesShortReads() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CorsoProgressUnitSuite struct {
|
type CorsoProgressUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
targetFilePath path.Path
|
targetFilePath path.Path
|
||||||
targetFileName string
|
targetFileName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCorsoProgressUnitSuite(t *testing.T) {
|
func TestCorsoProgressUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(CorsoProgressUnitSuite))
|
suite.Run(t, &CorsoProgressUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *CorsoProgressUnitSuite) SetupSuite() {
|
func (suite *CorsoProgressUnitSuite) SetupSuite() {
|
||||||
@ -449,9 +444,11 @@ func (suite *CorsoProgressUnitSuite) TestFinishedFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, cachedTest := range table {
|
for _, cachedTest := range table {
|
||||||
suite.T().Run(cachedTest.name, func(outerT *testing.T) {
|
suite.Run(cachedTest.name, func() {
|
||||||
for _, test := range finishedFileTable {
|
for _, test := range finishedFileTable {
|
||||||
outerT.Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
bd := &details.Builder{}
|
bd := &details.Builder{}
|
||||||
cp := corsoProgress{
|
cp := corsoProgress{
|
||||||
UploadProgress: &snapshotfs.NullUploadProgress{},
|
UploadProgress: &snapshotfs.NullUploadProgress{},
|
||||||
@ -632,7 +629,9 @@ func (suite *CorsoProgressUnitSuite) TestFinishedFileBaseItemDoesntBuildHierarch
|
|||||||
|
|
||||||
func (suite *CorsoProgressUnitSuite) TestFinishedHashingFile() {
|
func (suite *CorsoProgressUnitSuite) TestFinishedHashingFile() {
|
||||||
for _, test := range finishedFileTable {
|
for _, test := range finishedFileTable {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
bd := &details.Builder{}
|
bd := &details.Builder{}
|
||||||
cp := corsoProgress{
|
cp := corsoProgress{
|
||||||
UploadProgress: &snapshotfs.NullUploadProgress{},
|
UploadProgress: &snapshotfs.NullUploadProgress{},
|
||||||
@ -654,7 +653,7 @@ func (suite *CorsoProgressUnitSuite) TestFinishedHashingFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HierarchyBuilderUnitSuite struct {
|
type HierarchyBuilderUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
testStoragePath path.Path
|
testStoragePath path.Path
|
||||||
testLocationPath path.Path
|
testLocationPath path.Path
|
||||||
}
|
}
|
||||||
@ -671,7 +670,7 @@ func (suite *HierarchyBuilderUnitSuite) SetupSuite() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHierarchyBuilderUnitSuite(t *testing.T) {
|
func TestHierarchyBuilderUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(HierarchyBuilderUnitSuite))
|
suite.Run(t, &HierarchyBuilderUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTree() {
|
func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTree() {
|
||||||
@ -812,7 +811,9 @@ func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTree_MixedDirectory()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
progress := &corsoProgress{
|
progress := &corsoProgress{
|
||||||
pending: map[string]*itemDetails{},
|
pending: map[string]*itemDetails{},
|
||||||
errs: fault.New(true),
|
errs: fault.New(true),
|
||||||
@ -916,7 +917,9 @@ func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTree_Fails() {
|
|||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
_, err := inflateDirTree(ctx, nil, nil, test.layout, nil, nil)
|
_, err := inflateDirTree(ctx, nil, nil, test.layout, nil, nil)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
})
|
})
|
||||||
@ -997,7 +1000,9 @@ func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTreeErrors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
tester.LogTimeOfTest(t)
|
tester.LogTimeOfTest(t)
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
@ -1286,7 +1291,9 @@ func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTreeSingleSubtree() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
tester.LogTimeOfTest(t)
|
tester.LogTimeOfTest(t)
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
@ -2061,7 +2068,9 @@ func (suite *HierarchyBuilderUnitSuite) TestBuildDirectoryTreeMultipleSubdirecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
tester.LogTimeOfTest(t)
|
tester.LogTimeOfTest(t)
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
|
|||||||
@ -85,15 +85,13 @@ func testForFiles(
|
|||||||
assert.Equal(t, len(expected), count)
|
assert.Equal(t, len(expected), count)
|
||||||
}
|
}
|
||||||
|
|
||||||
//revive:disable:context-as-argument
|
|
||||||
func checkSnapshotTags(
|
func checkSnapshotTags(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
ctx context.Context,
|
ctx context.Context, //revive:disable-line:context-as-argument
|
||||||
rep repo.Repository,
|
rep repo.Repository,
|
||||||
expectedTags map[string]string,
|
expectedTags map[string]string,
|
||||||
snapshotID string,
|
snapshotID string,
|
||||||
) {
|
) {
|
||||||
//revive:enable:context-as-argument
|
|
||||||
man, err := snapshot.LoadSnapshot(ctx, rep, manifest.ID(snapshotID))
|
man, err := snapshot.LoadSnapshot(ctx, rep, manifest.ID(snapshotID))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expectedTags, man.Tags)
|
assert.Equal(t, expectedTags, man.Tags)
|
||||||
@ -103,7 +101,7 @@ func checkSnapshotTags(
|
|||||||
// unit tests
|
// unit tests
|
||||||
// ---------------
|
// ---------------
|
||||||
type KopiaUnitSuite struct {
|
type KopiaUnitSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
testPath path.Path
|
testPath path.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +122,7 @@ func (suite *KopiaUnitSuite) SetupSuite() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKopiaUnitSuite(t *testing.T) {
|
func TestKopiaUnitSuite(t *testing.T) {
|
||||||
suite.Run(t, new(KopiaUnitSuite))
|
suite.Run(t, &KopiaUnitSuite{Suite: tester.NewUnitSuite(t)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KopiaUnitSuite) TestCloseWithoutInitDoesNotPanic() {
|
func (suite *KopiaUnitSuite) TestCloseWithoutInitDoesNotPanic() {
|
||||||
@ -141,7 +139,7 @@ func (suite *KopiaUnitSuite) TestCloseWithoutInitDoesNotPanic() {
|
|||||||
// integration tests that use kopia
|
// integration tests that use kopia
|
||||||
// ---------------
|
// ---------------
|
||||||
type KopiaIntegrationSuite struct {
|
type KopiaIntegrationSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
w *Wrapper
|
w *Wrapper
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
flush func()
|
flush func()
|
||||||
@ -153,17 +151,16 @@ type KopiaIntegrationSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKopiaIntegrationSuite(t *testing.T) {
|
func TestKopiaIntegrationSuite(t *testing.T) {
|
||||||
tester.RunOnAny(
|
suite.Run(t, &KopiaIntegrationSuite{
|
||||||
t,
|
Suite: tester.NewIntegrationSuite(
|
||||||
tester.CorsoCITests,
|
t,
|
||||||
tester.CorsoKopiaWrapperTests)
|
[][]string{tester.AWSStorageCredEnvs},
|
||||||
|
tester.CorsoKopiaWrapperTests,
|
||||||
suite.Run(t, new(KopiaIntegrationSuite))
|
),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KopiaIntegrationSuite) SetupSuite() {
|
func (suite *KopiaIntegrationSuite) SetupSuite() {
|
||||||
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
|
|
||||||
|
|
||||||
tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory(
|
tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
testUser,
|
||||||
@ -266,7 +263,9 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections() {
|
|||||||
prevSnaps := []IncrementalBase{}
|
prevSnaps := []IncrementalBase{}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
stats, deets, _, err := suite.w.BackupCollections(
|
stats, deets, _, err := suite.w.BackupCollections(
|
||||||
suite.ctx,
|
suite.ctx,
|
||||||
prevSnaps,
|
prevSnaps,
|
||||||
@ -530,7 +529,9 @@ func (suite *KopiaIntegrationSuite) TestBackupCollectionsHandlesNoCollections()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
@ -551,7 +552,7 @@ func (suite *KopiaIntegrationSuite) TestBackupCollectionsHandlesNoCollections()
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KopiaSimpleRepoIntegrationSuite struct {
|
type KopiaSimpleRepoIntegrationSuite struct {
|
||||||
suite.Suite
|
tester.Suite
|
||||||
w *Wrapper
|
w *Wrapper
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
snapshotID manifest.ID
|
snapshotID manifest.ID
|
||||||
@ -566,17 +567,16 @@ type KopiaSimpleRepoIntegrationSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKopiaSimpleRepoIntegrationSuite(t *testing.T) {
|
func TestKopiaSimpleRepoIntegrationSuite(t *testing.T) {
|
||||||
tester.RunOnAny(
|
suite.Run(t, &KopiaSimpleRepoIntegrationSuite{
|
||||||
t,
|
Suite: tester.NewIntegrationSuite(
|
||||||
tester.CorsoCITests,
|
t,
|
||||||
tester.CorsoKopiaWrapperTests)
|
[][]string{tester.AWSStorageCredEnvs},
|
||||||
|
tester.CorsoKopiaWrapperTests,
|
||||||
suite.Run(t, new(KopiaSimpleRepoIntegrationSuite))
|
),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *KopiaSimpleRepoIntegrationSuite) SetupSuite() {
|
func (suite *KopiaSimpleRepoIntegrationSuite) SetupSuite() {
|
||||||
tester.MustGetEnvSets(suite.T(), tester.AWSStorageCredEnvs)
|
|
||||||
|
|
||||||
tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory(
|
tmp, err := path.Builder{}.Append(testInboxDir).ToDataLayerExchangePathForCategory(
|
||||||
testTenant,
|
testTenant,
|
||||||
testUser,
|
testUser,
|
||||||
@ -808,7 +808,9 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestBackupExcludeItem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
var excluded map[string]struct{}
|
var excluded map[string]struct{}
|
||||||
if test.excludeItem {
|
if test.excludeItem {
|
||||||
excluded = map[string]struct{}{
|
excluded = map[string]struct{}{
|
||||||
@ -923,7 +925,9 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestRestoreMultipleItems() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
// May slightly overallocate as only items that are actually in our map
|
// May slightly overallocate as only items that are actually in our map
|
||||||
// are expected. The rest are errors, but best-effort says it should carry
|
// are expected. The rest are errors, but best-effort says it should carry
|
||||||
// on even then.
|
// on even then.
|
||||||
@ -986,7 +990,9 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestRestoreMultipleItems_Errors()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
c, err := suite.w.RestoreMultipleItems(
|
c, err := suite.w.RestoreMultipleItems(
|
||||||
suite.ctx,
|
suite.ctx,
|
||||||
test.snapshotID,
|
test.snapshotID,
|
||||||
@ -1037,7 +1043,9 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestDeleteSnapshot_BadIDs() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.Run(test.name, func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
test.expect(t, suite.w.DeleteSnapshot(suite.ctx, test.snapshotID))
|
test.expect(t, suite.w.DeleteSnapshot(suite.ctx, test.snapshotID))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user