Fix unit tests that fail when not running with env vars (#2089)
## Description Refactoring and new code additions have led to some unit tests that fail unless testing is run with the proper env vars. Fixup code to either skip those tests or provide them with the proper information so they pass * some tests moved from unit tests to integration tests * function to get credentials with bogus info for unit tests * skip some tests if env vars not passed ## 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 - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🧹 Tech Debt/Cleanup ## Issue(s) * closes #2052 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
85b5877987
commit
778a60774a
@ -95,7 +95,7 @@ func TestServiceIteratorsSuite(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ServiceIteratorsSuite) SetupSuite() {
|
func (suite *ServiceIteratorsSuite) SetupSuite() {
|
||||||
a := tester.NewM365Account(suite.T())
|
a := tester.NewMockM365Account(suite.T())
|
||||||
m365, err := a.M365Config()
|
m365, err := a.M365Config()
|
||||||
require.NoError(suite.T(), err)
|
require.NoError(suite.T(), err)
|
||||||
suite.creds = m365
|
suite.creds = m365
|
||||||
@ -343,7 +343,7 @@ func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections() {
|
|||||||
func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_incrementals() {
|
func (suite *ServiceIteratorsSuite) TestFilterContainersAndFillCollections_incrementals() {
|
||||||
var (
|
var (
|
||||||
userID = "user_id"
|
userID = "user_id"
|
||||||
tenantID = tester.M365TenantID(suite.T())
|
tenantID = suite.creds.AzureTenantID
|
||||||
cat = path.EmailCategory // doesn't matter which one we use,
|
cat = path.EmailCategory // doesn't matter which one we use,
|
||||||
qp = graph.QueryParams{
|
qp = graph.QueryParams{
|
||||||
Category: cat,
|
Category: cat,
|
||||||
|
|||||||
@ -24,7 +24,7 @@ func TestGraphUnitSuite(t *testing.T) {
|
|||||||
|
|
||||||
func (suite *GraphUnitSuite) SetupSuite() {
|
func (suite *GraphUnitSuite) SetupSuite() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
a := tester.NewM365Account(t)
|
a := tester.NewMockM365Account(t)
|
||||||
m365, err := a.M365Config()
|
m365, err := a.M365Config()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|||||||
@ -167,30 +167,6 @@ func (suite *DisconnectedGraphConnectorSuite) TestGraphConnector_ErrorChecking()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *DisconnectedGraphConnectorSuite) TestRestoreFailsBadService() {
|
|
||||||
ctx, flush := tester.NewContext()
|
|
||||||
defer flush()
|
|
||||||
|
|
||||||
var (
|
|
||||||
t = suite.T()
|
|
||||||
acct = tester.NewM365Account(t)
|
|
||||||
dest = tester.DefaultTestRestoreDestination()
|
|
||||||
gc = GraphConnector{wg: &sync.WaitGroup{}}
|
|
||||||
sel = selectors.Selector{
|
|
||||||
Service: selectors.ServiceUnknown,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
deets, err := gc.RestoreDataCollections(ctx, acct, sel, dest, nil)
|
|
||||||
assert.Error(t, err)
|
|
||||||
assert.NotNil(t, deets)
|
|
||||||
|
|
||||||
status := gc.AwaitStatus()
|
|
||||||
assert.Equal(t, 0, status.ObjectCount)
|
|
||||||
assert.Equal(t, 0, status.FolderCount)
|
|
||||||
assert.Equal(t, 0, status.Successful)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (suite *DisconnectedGraphConnectorSuite) TestVerifyBackupInputs() {
|
func (suite *DisconnectedGraphConnectorSuite) TestVerifyBackupInputs() {
|
||||||
users := []string{
|
users := []string{
|
||||||
"elliotReid@someHospital.org",
|
"elliotReid@someHospital.org",
|
||||||
|
|||||||
@ -212,6 +212,29 @@ func (suite *GraphConnectorIntegrationSuite) TestSetTenantSites() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *GraphConnectorIntegrationSuite) TestRestoreFailsBadService() {
|
||||||
|
ctx, flush := tester.NewContext()
|
||||||
|
defer flush()
|
||||||
|
|
||||||
|
var (
|
||||||
|
t = suite.T()
|
||||||
|
acct = tester.NewM365Account(t)
|
||||||
|
dest = tester.DefaultTestRestoreDestination()
|
||||||
|
sel = selectors.Selector{
|
||||||
|
Service: selectors.ServiceUnknown,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
deets, err := suite.connector.RestoreDataCollections(ctx, acct, sel, dest, nil)
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.NotNil(t, deets)
|
||||||
|
|
||||||
|
status := suite.connector.AwaitStatus()
|
||||||
|
assert.Equal(t, 0, status.ObjectCount)
|
||||||
|
assert.Equal(t, 0, status.FolderCount)
|
||||||
|
assert.Equal(t, 0, status.Successful)
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() {
|
func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() {
|
||||||
dest := tester.DefaultTestRestoreDestination()
|
dest := tester.DefaultTestRestoreDestination()
|
||||||
table := []struct {
|
table := []struct {
|
||||||
|
|||||||
@ -25,6 +25,12 @@ type SharePointCollectionSuite struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSharePointCollectionSuite(t *testing.T) {
|
func TestSharePointCollectionSuite(t *testing.T) {
|
||||||
|
tester.RunOnAny(
|
||||||
|
t,
|
||||||
|
tester.CorsoCITests,
|
||||||
|
tester.CorsoGraphConnectorTests,
|
||||||
|
tester.CorsoGraphConnectorSharePointTests)
|
||||||
|
|
||||||
suite.Run(t, new(SharePointCollectionSuite))
|
suite.Run(t, new(SharePointCollectionSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,3 +31,19 @@ func NewM365Account(t *testing.T) account.Account {
|
|||||||
|
|
||||||
return acc
|
return acc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewMockM365Account(t *testing.T) account.Account {
|
||||||
|
acc, err := account.NewAccount(
|
||||||
|
account.ProviderM365,
|
||||||
|
account.M365Config{
|
||||||
|
M365: credentials.M365{
|
||||||
|
AzureClientID: "12345",
|
||||||
|
AzureClientSecret: "abcde",
|
||||||
|
},
|
||||||
|
AzureTenantID: "09876",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
require.NoError(t, err, "initializing mock account")
|
||||||
|
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user