corso has a thousand bespoke approaches to setting the same info in all of its tests. This is a first step towards minimizing and standardizing the lift around that work. Future PRs will distribute these packages through the repo. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🤖 Supportability/Tests - [x] 🧹 Tech Debt/Cleanup #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
67 lines
1.3 KiB
Go
67 lines
1.3 KiB
Go
package m365
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/alcionai/clues"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/alcionai/corso/src/internal/tester"
|
|
"github.com/alcionai/corso/src/internal/tester/its"
|
|
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
|
"github.com/alcionai/corso/src/pkg/account"
|
|
)
|
|
|
|
type M365IntgSuite struct {
|
|
tester.Suite
|
|
m365 its.M365IntgTestSetup
|
|
}
|
|
|
|
func TestM365IntgSuite(t *testing.T) {
|
|
suite.Run(t, &M365IntgSuite{
|
|
Suite: tester.NewIntegrationSuite(
|
|
t,
|
|
[][]string{}),
|
|
})
|
|
}
|
|
|
|
func (suite *M365IntgSuite) SetupSuite() {
|
|
suite.m365 = its.GetM365(suite.T())
|
|
}
|
|
|
|
func (suite *M365IntgSuite) TestNewM365Client() {
|
|
table := []struct {
|
|
name string
|
|
acct func(t *testing.T) account.Account
|
|
expectErr assert.ErrorAssertionFunc
|
|
}{
|
|
{
|
|
name: "Valid Credentials",
|
|
acct: func(t *testing.T) account.Account {
|
|
return suite.m365.Acct
|
|
},
|
|
expectErr: assert.NoError,
|
|
},
|
|
{
|
|
name: "Invalid Credentials",
|
|
acct: func(t *testing.T) account.Account {
|
|
return tconfig.NewFakeM365Account(t)
|
|
},
|
|
expectErr: assert.Error,
|
|
},
|
|
}
|
|
|
|
for _, test := range table {
|
|
suite.Run(test.name, func() {
|
|
t := suite.T()
|
|
|
|
ctx, flush := tester.NewContext(t)
|
|
defer flush()
|
|
|
|
_, err := NewM365Client(ctx, test.acct(t))
|
|
test.expectErr(t, err, clues.ToCore(err))
|
|
})
|
|
}
|
|
}
|