corso/src/internal/operations/restore_test.go
Keepers 689c5cc1e9
separate tenantID from m365 creds (#231)
* separate tenantID from m365 creds

Now that account.Account is in place, tenant id needs
to get removed from the credential set (it isn't actually
a secret) and placed in the account configuration instead.
2022-06-27 13:54:37 -06:00

62 lines
1.5 KiB
Go

package operations_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"github.com/alcionai/corso/internal/kopia"
"github.com/alcionai/corso/internal/operations"
ctesting "github.com/alcionai/corso/internal/testing"
"github.com/alcionai/corso/pkg/account"
)
type RestoreOpIntegrationSuite struct {
suite.Suite
}
func TestRestoreOpIntegrationSuite(t *testing.T) {
if err := ctesting.RunOnAny(ctesting.CorsoCITests); err != nil {
t.Skip(err)
}
suite.Run(t, new(RestoreOpIntegrationSuite))
}
func (suite *RestoreOpIntegrationSuite) SetupSuite() {
_, err := ctesting.GetRequiredEnvVars(ctesting.M365AcctCredEnvs...)
require.NoError(suite.T(), err)
}
func (suite *RestoreOpIntegrationSuite) TestNewRestoreOperation() {
kw := &kopia.KopiaWrapper{}
acct, err := ctesting.NewM365Account()
require.NoError(suite.T(), err)
table := []struct {
name string
opts operations.OperationOpts
kw *kopia.KopiaWrapper
acct account.Account
targets []string
errCheck assert.ErrorAssertionFunc
}{
{"good", operations.OperationOpts{}, kw, acct, nil, assert.NoError},
{"missing kopia", operations.OperationOpts{}, nil, acct, nil, assert.Error},
}
for _, test := range table {
suite.T().Run(test.name, func(t *testing.T) {
_, err := operations.NewRestoreOperation(
context.Background(),
operations.OperationOpts{},
test.kw,
test.acct,
"restore-point-id",
nil)
test.errCheck(t, err)
})
}
}