corso/src/pkg/backup/details/iteminfo_test.go
Keepers c74585eafc
remove redundant type check (#4199)
info.itemType already looks through each service entry to find the item type.  A service nil check is redundant. Adds a qol func for asking if an itemInfo is a driveish item.

---

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

- [x]  No

#### Type of change

- [x] 🐛 Bugfix

#### Issue(s)

* #3990 

#### Test Plan

- [x] 💪 Manual
- [x]  Unit test
- [x] 💚 E2E
2023-09-07 18:30:46 +00:00

87 lines
1.5 KiB
Go

package details
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/alcionai/corso/src/internal/tester"
)
type ItemInfoUnitSuite struct {
tester.Suite
}
func TestItemInfoUnitSuite(t *testing.T) {
suite.Run(t, &ItemInfoUnitSuite{Suite: tester.NewUnitSuite(t)})
}
func (suite *ItemInfoUnitSuite) TestItemInfo_IsDriveItem() {
table := []struct {
name string
ii ItemInfo
expect assert.BoolAssertionFunc
}{
{
name: "onedrive item",
ii: ItemInfo{
OneDrive: &OneDriveInfo{
ItemType: OneDriveItem,
},
},
expect: assert.True,
},
{
name: "sharepoint library",
ii: ItemInfo{
SharePoint: &SharePointInfo{
ItemType: SharePointLibrary,
},
},
expect: assert.True,
},
{
name: "sharepoint page",
ii: ItemInfo{
SharePoint: &SharePointInfo{
ItemType: SharePointPage,
},
},
expect: assert.False,
},
{
name: "groups library",
ii: ItemInfo{
Groups: &GroupsInfo{
ItemType: SharePointLibrary,
},
},
expect: assert.True,
},
{
name: "groups channel message",
ii: ItemInfo{
Groups: &GroupsInfo{
ItemType: GroupsChannelMessage,
},
},
expect: assert.False,
},
{
name: "exchange anything",
ii: ItemInfo{
Groups: &GroupsInfo{
ItemType: ExchangeMail,
},
},
expect: assert.False,
},
}
for _, test := range table {
suite.Run(test.name, func() {
test.expect(suite.T(), test.ii.isDriveItem())
})
}
}