2023-01-24 12:58:10 +00:00
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-04-21 08:30:20 +00:00
|
|
|
"github.com/databricks/databricks-sdk-go/service/iam"
|
2023-01-24 12:58:10 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2023-02-20 13:34:48 +00:00
|
|
|
func TestPathToRepoPath(t *testing.T) {
|
2023-04-21 08:30:20 +00:00
|
|
|
me := iam.User{
|
2023-02-20 13:34:48 +00:00
|
|
|
UserName: "jane@doe.com",
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "/Repos/jane@doe.com/foo", repoPathForPath(&me, "/Repos/jane@doe.com/foo/bar/qux"))
|
|
|
|
assert.Equal(t, "/Repos/jane@doe.com/foo", repoPathForPath(&me, "/Repos/jane@doe.com/foo/bar"))
|
|
|
|
assert.Equal(t, "/Repos/jane@doe.com/foo", repoPathForPath(&me, "/Repos/jane@doe.com/foo"))
|
|
|
|
|
|
|
|
// We expect this function to be called with a path nested under the user's repo path.
|
|
|
|
// If this is not the case it should return the input verbatim (albeit cleaned).
|
|
|
|
assert.Equal(t, "/Repos/jane@doe.com", repoPathForPath(&me, "/Repos/jane@doe.com"))
|
|
|
|
assert.Equal(t, "/Repos/hello@world.com/foo/bar/qux", repoPathForPath(&me, "/Repos/hello@world.com/foo/bar/qux"))
|
|
|
|
assert.Equal(t, "/Repos/hello@world.com/foo/bar/qux", repoPathForPath(&me, "/Repos/hello@world.com/foo/bar/qux/."))
|
|
|
|
}
|