corso/src/pkg/services/m365/m365_test.go
Keepers 963d78b75e
move service api to client methods (#4701)
sdk consumers need a way to configure the graph api client options when using the services api.  This is the first in a two-part change to expose those options.  This step moves the api to a client-based set of methods instead of free functions.  The next step will add client configuration to the service client.

---

#### Does this PR need a docs update or release note?

- [x] 🕐 Yes, but in a later PR

#### Type of change

- [x] 🌻 Feature

#### Test Plan

- [x] 💚 E2E
2023-11-17 01:03:57 +00:00

62 lines
1.2 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/tconfig"
"github.com/alcionai/corso/src/pkg/account"
)
type M365IntgSuite struct {
tester.Suite
}
func TestM365IntgSuite(t *testing.T) {
suite.Run(t, &M365IntgSuite{
Suite: tester.NewIntegrationSuite(
t,
[][]string{}),
})
}
func (suite *userIntegrationSuite) TestNewM365Client() {
t := suite.T()
ctx, flush := tester.NewContext(t)
defer flush()
_, err := NewM365Client(ctx, tconfig.NewM365Account(t))
assert.NoError(t, err, clues.ToCore(err))
}
func (suite *userIntegrationSuite) TestNewM365Client_invalidCredentials() {
table := []struct {
name string
acct func(t *testing.T) account.Account
}{
{
name: "Invalid Credentials",
acct: func(t *testing.T) account.Account {
return tconfig.NewFakeM365Account(t)
},
},
}
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))
assert.Error(t, err, clues.ToCore(err))
})
}
}