GC: Container Resolver tests consolidation (#1363)
## Description Grouping of event and contact folder caches to the same file. MailFolderCache left in a different folder until it can be decided where the tests before <!-- Insert PR description--> ## Type of change - [x] 🤖 Test ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> ## Test Plan - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
4b81d1b9b8
commit
0e29655645
@ -1,88 +0,0 @@
|
|||||||
package exchange
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"github.com/stretchr/testify/suite"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ContactFolderCacheIntegrationSuite struct {
|
|
||||||
suite.Suite
|
|
||||||
gs graph.Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func (suite *ContactFolderCacheIntegrationSuite) SetupSuite() {
|
|
||||||
t := suite.T()
|
|
||||||
|
|
||||||
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
a := tester.NewM365Account(t)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
m365, err := a.M365Config()
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
service, err := createService(m365, false)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
suite.gs = service
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContactFolderCacheIntegrationSuite(t *testing.T) {
|
|
||||||
if err := tester.RunOnAny(
|
|
||||||
tester.CorsoCITests,
|
|
||||||
tester.CorsoGraphConnectorTests,
|
|
||||||
tester.CorsoGraphConnectorExchangeTests,
|
|
||||||
); err != nil {
|
|
||||||
t.Skip(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
suite.Run(t, new(ContactFolderCacheIntegrationSuite))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (suite *ContactFolderCacheIntegrationSuite) TestPopulate() {
|
|
||||||
ctx, flush := tester.NewContext()
|
|
||||||
defer flush()
|
|
||||||
|
|
||||||
cfc := contactFolderCache{
|
|
||||||
userID: tester.M365UserID(suite.T()),
|
|
||||||
gs: suite.gs,
|
|
||||||
}
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
folderName string
|
|
||||||
basePath string
|
|
||||||
canFind assert.BoolAssertionFunc
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Default Contact Cache",
|
|
||||||
folderName: DefaultContactFolder,
|
|
||||||
basePath: DefaultContactFolder,
|
|
||||||
canFind: assert.True,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Default Contact Hidden",
|
|
||||||
folderName: DefaultContactFolder,
|
|
||||||
canFind: assert.False,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Name Not in Cache",
|
|
||||||
folderName: "testFooBarWhoBar",
|
|
||||||
canFind: assert.False,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, test := range tests {
|
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
|
||||||
require.NoError(t, cfc.Populate(ctx, DefaultContactFolder, test.basePath))
|
|
||||||
_, isFound := cfc.PathInCache(test.folderName)
|
|
||||||
test.canFind(t, isFound)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -11,12 +11,12 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EventCalendarCacheSuite struct {
|
type CacheResolverSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
gs graph.Service
|
gs graph.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEventCalendarCacheIntegrationSuite(t *testing.T) {
|
func TestCacheResolverIntegrationSuite(t *testing.T) {
|
||||||
if err := tester.RunOnAny(
|
if err := tester.RunOnAny(
|
||||||
tester.CorsoCITests,
|
tester.CorsoCITests,
|
||||||
tester.CorsoGraphConnectorTests,
|
tester.CorsoGraphConnectorTests,
|
||||||
@ -25,10 +25,10 @@ func TestEventCalendarCacheIntegrationSuite(t *testing.T) {
|
|||||||
t.Skip(err)
|
t.Skip(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
suite.Run(t, new(EventCalendarCacheSuite))
|
suite.Run(t, new(CacheResolverSuite))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EventCalendarCacheSuite) SetupSuite() {
|
func (suite *CacheResolverSuite) SetupSuite() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
|
|
||||||
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
|
_, err := tester.GetRequiredEnvVars(tester.M365AcctCredEnvs...)
|
||||||
@ -46,7 +46,7 @@ func (suite *EventCalendarCacheSuite) SetupSuite() {
|
|||||||
suite.gs = service
|
suite.gs = service
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *EventCalendarCacheSuite) TestPopulate() {
|
func (suite *CacheResolverSuite) TestPopulate() {
|
||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
@ -55,33 +55,65 @@ func (suite *EventCalendarCacheSuite) TestPopulate() {
|
|||||||
gs: suite.gs,
|
gs: suite.gs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfc := contactFolderCache{
|
||||||
|
userID: tester.M365UserID(suite.T()),
|
||||||
|
gs: suite.gs,
|
||||||
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name, folderName, root, basePath string
|
||||||
folderName string
|
resolver graph.ContainerResolver
|
||||||
basePath string
|
canFind assert.BoolAssertionFunc
|
||||||
canFind assert.BoolAssertionFunc
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Default Event Cache",
|
name: "Default Event Cache",
|
||||||
folderName: DefaultCalendar,
|
folderName: DefaultCalendar,
|
||||||
|
root: DefaultCalendar,
|
||||||
basePath: DefaultCalendar,
|
basePath: DefaultCalendar,
|
||||||
|
resolver: &ecc,
|
||||||
canFind: assert.True,
|
canFind: assert.True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Default Event Folder Hidden",
|
name: "Default Event Folder Hidden",
|
||||||
|
root: DefaultCalendar,
|
||||||
folderName: DefaultContactFolder,
|
folderName: DefaultContactFolder,
|
||||||
canFind: assert.False,
|
canFind: assert.False,
|
||||||
|
resolver: &ecc,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Name Not in Cache",
|
name: "Name Not in Cache",
|
||||||
folderName: "testFooBarWhoBar",
|
folderName: "testFooBarWhoBar",
|
||||||
|
root: DefaultCalendar,
|
||||||
canFind: assert.False,
|
canFind: assert.False,
|
||||||
|
resolver: &ecc,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Default Contact Cache",
|
||||||
|
folderName: DefaultContactFolder,
|
||||||
|
root: DefaultContactFolder,
|
||||||
|
basePath: DefaultContactFolder,
|
||||||
|
canFind: assert.True,
|
||||||
|
resolver: &cfc,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Default Contact Hidden",
|
||||||
|
folderName: DefaultContactFolder,
|
||||||
|
root: DefaultContactFolder,
|
||||||
|
canFind: assert.False,
|
||||||
|
resolver: &cfc,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Name Not in Cache",
|
||||||
|
folderName: "testFooBarWhoBar",
|
||||||
|
root: DefaultContactFolder,
|
||||||
|
canFind: assert.False,
|
||||||
|
resolver: &cfc,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
require.NoError(t, ecc.Populate(ctx, DefaultCalendar, test.basePath))
|
require.NoError(t, test.resolver.Populate(ctx, test.root, test.basePath))
|
||||||
_, isFound := ecc.PathInCache(test.folderName)
|
_, isFound := test.resolver.PathInCache(test.folderName)
|
||||||
test.canFind(t, isFound)
|
test.canFind(t, isFound)
|
||||||
assert.Greater(t, len(ecc.cache), 0)
|
assert.Greater(t, len(ecc.cache), 0)
|
||||||
})
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user