fstests: make integration tests work with connection strings in remotes

This commit is contained in:
Nick Craig-Wood 2023-04-28 12:22:44 +01:00
parent 3567a47258
commit 12761b3058
1 changed files with 17 additions and 7 deletions

View File

@ -526,23 +526,33 @@ func Run(t *testing.T, opt *Opt) {
t.Run("FsName", func(t *testing.T) { t.Run("FsName", func(t *testing.T) {
skipIfNotOk(t) skipIfNotOk(t)
got := removeConfigID(f.Name()) got := removeConfigID(f.Name())
want := remoteName[:strings.LastIndex(remoteName, ":")+1] var want string
if isLocalRemote { if isLocalRemote {
want = "local:" want = "local"
} else {
want = remoteName[:strings.LastIndex(remoteName, ":")]
comma := strings.IndexRune(remoteName, ',')
if comma >= 0 {
want = want[:comma]
}
} }
require.Equal(t, want, got+":") require.Equal(t, want, got)
}) })
// TestFsRoot tests the Root method // TestFsRoot tests the Root method
t.Run("FsRoot", func(t *testing.T) { t.Run("FsRoot", func(t *testing.T) {
skipIfNotOk(t) skipIfNotOk(t)
name := removeConfigID(f.Name()) + ":" got := f.Root()
root := f.Root() want := subRemoteName
colon := strings.LastIndex(want, ":")
if colon >= 0 {
want = want[colon+1:]
}
if isLocalRemote { if isLocalRemote {
// only check last path element on local // only check last path element on local
require.Equal(t, filepath.Base(subRemoteName), filepath.Base(root)) require.Equal(t, filepath.Base(subRemoteName), filepath.Base(got))
} else { } else {
require.Equal(t, subRemoteName, name+root) require.Equal(t, want, got)
} }
}) })