corso/src/internal/operations/operation_test.go
ashmrtn 70e7a1e2d3
Split KopiaWrapper into handle and backup/restore logic (#281)
* Split KopiaWrapper into repo handle and logic

With ModelStore, multiple structs need a reference to the kopia repo.
Make a small wrapper class (conn) that can open and initialize a repo. The
wrapper handles concurrent closes and opens and does ref counting to
ensure it only drops the kopia handle when the last reference is closed.

Rename KopiaWrapper to Wrapper and keep backup/restore functionality
in it.
2022-07-06 11:09:35 -07:00

43 lines
851 B
Go

package operations
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/alcionai/corso/internal/kopia"
)
type OperationSuite struct {
suite.Suite
}
func TestOperationSuite(t *testing.T) {
suite.Run(t, new(OperationSuite))
}
func (suite *OperationSuite) TestNewOperation() {
t := suite.T()
op := newOperation(Options{}, nil)
assert.NotNil(t, op.ID)
}
func (suite *OperationSuite) TestOperation_Validate() {
kwStub := &kopia.Wrapper{}
table := []struct {
name string
kw *kopia.Wrapper
errCheck assert.ErrorAssertionFunc
}{
{"good", kwStub, assert.NoError},
{"missing kopia", nil, assert.Error},
}
for _, test := range table {
suite.T().Run(test.name, func(t *testing.T) {
op := newOperation(Options{}, test.kw)
test.errCheck(t, op.validate())
})
}
}