move largeItem client constructor into new GC (#3130)
It's an unnecessary paramter. Plus, this sets up the next pr to have a smaller footprint. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #3129 #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
fe644ae2be
commit
d5eee4479d
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/connector"
|
"github.com/alcionai/corso/src/internal/connector"
|
||||||
exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock"
|
exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"github.com/alcionai/corso/src/internal/version"
|
"github.com/alcionai/corso/src/internal/version"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
@ -137,7 +136,6 @@ func getGCAndVerifyUser(ctx context.Context, userID string) (*connector.GraphCon
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
ctx,
|
ctx,
|
||||||
graph.HTTPClient(graph.NoTimeout()),
|
|
||||||
acct,
|
acct,
|
||||||
connector.Users,
|
connector.Users,
|
||||||
errs)
|
errs)
|
||||||
|
|||||||
@ -270,7 +270,7 @@ func getGC(ctx context.Context) (account.Account, *connector.GraphConnector, err
|
|||||||
// TODO: log/print recoverable errors
|
// TODO: log/print recoverable errors
|
||||||
errs := fault.New(false)
|
errs := fault.New(false)
|
||||||
|
|
||||||
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), acct, connector.Users, errs)
|
gc, err := connector.NewGraphConnector(ctx, acct, connector.Users, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return account.Account{}, nil, Only(ctx, clues.Wrap(err, "connecting to graph api"))
|
return account.Account{}, nil, Only(ctx, clues.Wrap(err, "connecting to graph api"))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,7 +58,7 @@ func (suite *DataCollectionIntgSuite) TestExchangeDataCollection() {
|
|||||||
|
|
||||||
selUsers := []string{suite.user}
|
selUsers := []string{suite.user}
|
||||||
|
|
||||||
connector := loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Users)
|
connector := loadConnector(ctx, suite.T(), Users)
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
getSelector func(t *testing.T) selectors.Selector
|
getSelector func(t *testing.T) selectors.Selector
|
||||||
@ -141,7 +141,7 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner()
|
|||||||
|
|
||||||
owners := []string{"snuffleupagus"}
|
owners := []string{"snuffleupagus"}
|
||||||
|
|
||||||
connector := loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Users)
|
connector := loadConnector(ctx, suite.T(), Users)
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
getSelector func(t *testing.T) selectors.Selector
|
getSelector func(t *testing.T) selectors.Selector
|
||||||
@ -226,7 +226,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() {
|
|||||||
|
|
||||||
selSites := []string{suite.site}
|
selSites := []string{suite.site}
|
||||||
|
|
||||||
connector := loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Sites)
|
connector := loadConnector(ctx, suite.T(), Sites)
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
expected int
|
expected int
|
||||||
@ -315,7 +315,7 @@ func (suite *SPCollectionIntgSuite) SetupSuite() {
|
|||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
suite.connector = loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Sites)
|
suite.connector = loadConnector(ctx, suite.T(), Sites)
|
||||||
suite.user = tester.M365UserID(suite.T())
|
suite.user = tester.M365UserID(suite.T())
|
||||||
|
|
||||||
tester.LogTimeOfTest(suite.T())
|
tester.LogTimeOfTest(suite.T())
|
||||||
@ -328,7 +328,7 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Libraries() {
|
|||||||
var (
|
var (
|
||||||
t = suite.T()
|
t = suite.T()
|
||||||
siteID = tester.M365SiteID(t)
|
siteID = tester.M365SiteID(t)
|
||||||
gc = loadConnector(ctx, t, graph.HTTPClient(graph.NoTimeout()), Sites)
|
gc = loadConnector(ctx, t, Sites)
|
||||||
siteIDs = []string{siteID}
|
siteIDs = []string{siteID}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ func (suite *SPCollectionIntgSuite) TestCreateSharePointCollection_Lists() {
|
|||||||
var (
|
var (
|
||||||
t = suite.T()
|
t = suite.T()
|
||||||
siteID = tester.M365SiteID(t)
|
siteID = tester.M365SiteID(t)
|
||||||
gc = loadConnector(ctx, t, graph.HTTPClient(graph.NoTimeout()), Sites)
|
gc = loadConnector(ctx, t, Sites)
|
||||||
siteIDs = []string{siteID}
|
siteIDs = []string{siteID}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -58,7 +58,6 @@ type GraphConnector struct {
|
|||||||
|
|
||||||
func NewGraphConnector(
|
func NewGraphConnector(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
itemClient *http.Client,
|
|
||||||
acct account.Account,
|
acct account.Account,
|
||||||
r resource,
|
r resource,
|
||||||
errs *fault.Bus,
|
errs *fault.Bus,
|
||||||
@ -89,7 +88,7 @@ func NewGraphConnector(
|
|||||||
Service: service,
|
Service: service,
|
||||||
|
|
||||||
credentials: creds,
|
credentials: creds,
|
||||||
itemClient: itemClient,
|
itemClient: graph.HTTPClient(graph.NoTimeout()),
|
||||||
ownerLookup: rc,
|
ownerLookup: rc,
|
||||||
tenant: acct.ID(),
|
tenant: acct.ID(),
|
||||||
wg: &sync.WaitGroup{},
|
wg: &sync.WaitGroup{},
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -1284,10 +1283,10 @@ func getSelectorWith(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConnector(ctx context.Context, t *testing.T, itemClient *http.Client, r resource) *GraphConnector {
|
func loadConnector(ctx context.Context, t *testing.T, r resource) *GraphConnector {
|
||||||
a := tester.NewM365Account(t)
|
a := tester.NewM365Account(t)
|
||||||
|
|
||||||
connector, err := NewGraphConnector(ctx, itemClient, a, r, fault.New(true))
|
connector, err := NewGraphConnector(ctx, a, r, fault.New(true))
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
return connector
|
return connector
|
||||||
|
|||||||
@ -445,7 +445,7 @@ func (suite *GraphConnectorSharePointIntegrationSuite) SetupSuite() {
|
|||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
si := suiteInfoImpl{
|
si := suiteInfoImpl{
|
||||||
connector: loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Sites),
|
connector: loadConnector(ctx, suite.T(), Sites),
|
||||||
user: tester.M365UserID(suite.T()),
|
user: tester.M365UserID(suite.T()),
|
||||||
secondaryUser: tester.SecondaryM365UserID(suite.T()),
|
secondaryUser: tester.SecondaryM365UserID(suite.T()),
|
||||||
acct: tester.NewM365Account(suite.T()),
|
acct: tester.NewM365Account(suite.T()),
|
||||||
@ -492,7 +492,7 @@ func (suite *GraphConnectorOneDriveIntegrationSuite) SetupSuite() {
|
|||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
si := suiteInfoImpl{
|
si := suiteInfoImpl{
|
||||||
connector: loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Users),
|
connector: loadConnector(ctx, suite.T(), Users),
|
||||||
user: tester.M365UserID(suite.T()),
|
user: tester.M365UserID(suite.T()),
|
||||||
secondaryUser: tester.SecondaryM365UserID(suite.T()),
|
secondaryUser: tester.SecondaryM365UserID(suite.T()),
|
||||||
acct: tester.NewM365Account(suite.T()),
|
acct: tester.NewM365Account(suite.T()),
|
||||||
@ -551,7 +551,7 @@ func (suite *GraphConnectorOneDriveNightlySuite) SetupSuite() {
|
|||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
si := suiteInfoImpl{
|
si := suiteInfoImpl{
|
||||||
connector: loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Users),
|
connector: loadConnector(ctx, suite.T(), Users),
|
||||||
user: tester.M365UserID(suite.T()),
|
user: tester.M365UserID(suite.T()),
|
||||||
secondaryUser: tester.SecondaryM365UserID(suite.T()),
|
secondaryUser: tester.SecondaryM365UserID(suite.T()),
|
||||||
acct: tester.NewM365Account(suite.T()),
|
acct: tester.NewM365Account(suite.T()),
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock"
|
exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/mock"
|
"github.com/alcionai/corso/src/internal/connector/mock"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
@ -312,7 +311,7 @@ func (suite *GraphConnectorIntegrationSuite) SetupSuite() {
|
|||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
suite.connector = loadConnector(ctx, suite.T(), graph.HTTPClient(graph.NoTimeout()), Users)
|
suite.connector = loadConnector(ctx, suite.T(), Users)
|
||||||
suite.user = tester.M365UserID(suite.T())
|
suite.user = tester.M365UserID(suite.T())
|
||||||
suite.secondaryUser = tester.SecondaryM365UserID(suite.T())
|
suite.secondaryUser = tester.SecondaryM365UserID(suite.T())
|
||||||
suite.acct = tester.NewM365Account(suite.T())
|
suite.acct = tester.NewM365Account(suite.T())
|
||||||
@ -490,7 +489,7 @@ func runRestore(
|
|||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
restoreGC := loadConnector(ctx, t, graph.HTTPClient(graph.NoTimeout()), config.resource)
|
restoreGC := loadConnector(ctx, t, config.resource)
|
||||||
restoreSel := getSelectorWith(t, config.service, config.resourceOwners, true)
|
restoreSel := getSelectorWith(t, config.service, config.resourceOwners, true)
|
||||||
deets, err := restoreGC.ConsumeRestoreCollections(
|
deets, err := restoreGC.ConsumeRestoreCollections(
|
||||||
ctx,
|
ctx,
|
||||||
@ -552,7 +551,7 @@ func runBackupAndCompare(
|
|||||||
nameToID[ro] = ro
|
nameToID[ro] = ro
|
||||||
}
|
}
|
||||||
|
|
||||||
backupGC := loadConnector(ctx, t, graph.HTTPClient(graph.NoTimeout()), config.resource)
|
backupGC := loadConnector(ctx, t, config.resource)
|
||||||
backupGC.IDNameLookup = common.IDsNames{IDToName: idToName, NameToID: nameToID}
|
backupGC.IDNameLookup = common.IDsNames{IDToName: idToName, NameToID: nameToID}
|
||||||
|
|
||||||
backupSel := backupSelectorForExpected(t, config.service, expectedDests)
|
backupSel := backupSelectorForExpected(t, config.service, expectedDests)
|
||||||
@ -1066,7 +1065,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames
|
|||||||
dest.ContainerName,
|
dest.ContainerName,
|
||||||
)
|
)
|
||||||
|
|
||||||
restoreGC := loadConnector(ctx, t, graph.HTTPClient(graph.NoTimeout()), test.resource)
|
restoreGC := loadConnector(ctx, t, test.resource)
|
||||||
deets, err := restoreGC.ConsumeRestoreCollections(
|
deets, err := restoreGC.ConsumeRestoreCollections(
|
||||||
ctx,
|
ctx,
|
||||||
version.Backup,
|
version.Backup,
|
||||||
@ -1095,7 +1094,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames
|
|||||||
|
|
||||||
// Run a backup and compare its output with what we put in.
|
// Run a backup and compare its output with what we put in.
|
||||||
|
|
||||||
backupGC := loadConnector(ctx, t, graph.HTTPClient(graph.NoTimeout()), test.resource)
|
backupGC := loadConnector(ctx, t, test.resource)
|
||||||
backupSel := backupSelectorForExpected(t, test.service, expectedDests)
|
backupSel := backupSelectorForExpected(t, test.service, expectedDests)
|
||||||
t.Log("Selective backup of", backupSel)
|
t.Log("Selective backup of", backupSel)
|
||||||
|
|
||||||
@ -1246,7 +1245,7 @@ func (suite *GraphConnectorIntegrationSuite) TestBackup_CreatesPrefixCollections
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
t = suite.T()
|
t = suite.T()
|
||||||
backupGC = loadConnector(ctx, t, graph.HTTPClient(graph.NoTimeout()), test.resource)
|
backupGC = loadConnector(ctx, t, test.resource)
|
||||||
backupSel = test.selectorFunc(t)
|
backupSel = test.selectorFunc(t)
|
||||||
errs = fault.New(true)
|
errs = fault.New(true)
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
|
|||||||
@ -115,7 +115,6 @@ func prepNewTestBackupOp(
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
ctx,
|
ctx,
|
||||||
graph.HTTPClient(graph.NoTimeout()),
|
|
||||||
acct,
|
acct,
|
||||||
connectorResource,
|
connectorResource,
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
@ -750,7 +749,6 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_exchangeIncrementals() {
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
ctx,
|
ctx,
|
||||||
graph.HTTPClient(graph.NoTimeout()),
|
|
||||||
acct,
|
acct,
|
||||||
connector.Users,
|
connector.Users,
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
@ -1203,7 +1201,6 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDriveIncrementals() {
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
ctx,
|
ctx,
|
||||||
graph.HTTPClient(graph.NoTimeout()),
|
|
||||||
acct,
|
acct,
|
||||||
connector.Users,
|
connector.Users,
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
|
|||||||
@ -273,7 +273,6 @@ func setupExchangeBackup(
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
ctx,
|
ctx,
|
||||||
graph.HTTPClient(graph.NoTimeout()),
|
|
||||||
acct,
|
acct,
|
||||||
connector.Users,
|
connector.Users,
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
@ -335,7 +334,6 @@ func setupSharePointBackup(
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
ctx,
|
ctx,
|
||||||
graph.HTTPClient(graph.NoTimeout()),
|
|
||||||
acct,
|
acct,
|
||||||
connector.Sites,
|
connector.Sites,
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
@ -493,7 +491,6 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoResults() {
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
ctx,
|
ctx,
|
||||||
graph.HTTPClient(graph.NoTimeout()),
|
|
||||||
suite.acct,
|
suite.acct,
|
||||||
connector.Users,
|
connector.Users,
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/common/crash"
|
"github.com/alcionai/corso/src/internal/common/crash"
|
||||||
"github.com/alcionai/corso/src/internal/connector"
|
"github.com/alcionai/corso/src/internal/connector"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"github.com/alcionai/corso/src/internal/events"
|
"github.com/alcionai/corso/src/internal/events"
|
||||||
@ -643,7 +642,7 @@ func connectToM365(
|
|||||||
resource = connector.Sites
|
resource = connector.Sites
|
||||||
}
|
}
|
||||||
|
|
||||||
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), acct, resource, errs)
|
gc, err := connector.NewGraphConnector(ctx, acct, resource, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user