In keeping with other changes that migrate shared metadata to the onedrive/metadata pkg for exported access. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #3135 #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package path_test
|
|
|
|
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 OneDrivePathSuite struct {
|
|
tester.Suite
|
|
}
|
|
|
|
func TestOneDrivePathSuite(t *testing.T) {
|
|
suite.Run(t, &OneDrivePathSuite{Suite: tester.NewUnitSuite(t)})
|
|
}
|
|
|
|
func (suite *OneDrivePathSuite) Test_ToOneDrivePath() {
|
|
const root = "root:"
|
|
|
|
tests := []struct {
|
|
name string
|
|
pathElements []string
|
|
expected *path.DrivePath
|
|
errCheck assert.ErrorAssertionFunc
|
|
}{
|
|
{
|
|
name: "Not enough path elements",
|
|
pathElements: []string{"drive", "driveID"},
|
|
errCheck: assert.Error,
|
|
},
|
|
{
|
|
name: "Root path",
|
|
pathElements: []string{"drive", "driveID", root},
|
|
expected: &path.DrivePath{DriveID: "driveID", Root: root, Folders: []string{}},
|
|
errCheck: assert.NoError,
|
|
},
|
|
{
|
|
name: "Deeper path",
|
|
pathElements: []string{"drive", "driveID", root, "folder1", "folder2"},
|
|
expected: &path.DrivePath{DriveID: "driveID", Root: root, Folders: []string{"folder1", "folder2"}},
|
|
errCheck: assert.NoError,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
suite.Run(tt.name, func() {
|
|
t := suite.T()
|
|
|
|
p, err := path.Build("tenant", "user", path.OneDriveService, path.FilesCategory, false, tt.pathElements...)
|
|
require.NoError(suite.T(), err, clues.ToCore(err))
|
|
|
|
got, err := path.ToDrivePath(p)
|
|
tt.errCheck(t, err)
|
|
if err != nil {
|
|
return
|
|
}
|
|
assert.Equal(suite.T(), tt.expected, got)
|
|
})
|
|
}
|
|
}
|