First pass for updating code outside of the path package to comply with ServiceResource tuple slices. Compliance is still incomplete, so the build and tests will still fail. Changes in this PR are focused on the easier-to-make changes, mostly generating ServiceResources where there were previously manual declarations of service and resource.
97 lines
1.8 KiB
Go
97 lines
1.8 KiB
Go
package data
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/alcionai/clues"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
"github.com/alcionai/corso/src/internal/tester"
|
|
"github.com/alcionai/corso/src/pkg/path"
|
|
)
|
|
|
|
type DataCollectionSuite struct {
|
|
tester.Suite
|
|
}
|
|
|
|
func TestDataCollectionSuite(t *testing.T) {
|
|
suite.Run(t, &DataCollectionSuite{Suite: tester.NewUnitSuite(t)})
|
|
}
|
|
|
|
func (suite *DataCollectionSuite) TestStateOf() {
|
|
fooP, err := path.Build(
|
|
"t",
|
|
[]path.ServiceResource{{
|
|
Service: path.ExchangeService,
|
|
ProtectedResource: "u",
|
|
}},
|
|
path.EmailCategory,
|
|
false,
|
|
"foo")
|
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
|
barP, err := path.Build(
|
|
"t",
|
|
[]path.ServiceResource{{
|
|
Service: path.ExchangeService,
|
|
ProtectedResource: "u",
|
|
}},
|
|
path.EmailCategory,
|
|
false,
|
|
"bar")
|
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
|
preP, err := path.Build(
|
|
"_t",
|
|
[]path.ServiceResource{{
|
|
Service: path.ExchangeService,
|
|
ProtectedResource: "u",
|
|
}},
|
|
path.EmailCategory,
|
|
false,
|
|
"foo")
|
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
|
|
|
table := []struct {
|
|
name string
|
|
prev path.Path
|
|
curr path.Path
|
|
expect CollectionState
|
|
}{
|
|
{
|
|
name: "new",
|
|
curr: fooP,
|
|
expect: NewState,
|
|
},
|
|
{
|
|
name: "not moved",
|
|
prev: fooP,
|
|
curr: fooP,
|
|
expect: NotMovedState,
|
|
},
|
|
{
|
|
name: "moved",
|
|
prev: fooP,
|
|
curr: barP,
|
|
expect: MovedState,
|
|
},
|
|
{
|
|
name: "moved if prefix changes",
|
|
prev: fooP,
|
|
curr: preP,
|
|
expect: MovedState,
|
|
},
|
|
{
|
|
name: "deleted",
|
|
prev: fooP,
|
|
expect: DeletedState,
|
|
},
|
|
}
|
|
for _, test := range table {
|
|
suite.Run(test.name, func() {
|
|
state := StateOf(test.prev, test.curr)
|
|
assert.Equal(suite.T(), test.expect, state)
|
|
})
|
|
}
|
|
}
|