mirror of
https://github.com/rclone/rclone.git
synced 2025-08-14 15:58:26 +02:00
cmd/gitannex: Port unit tests to fstest
This enables the unit tests to run on any given backend, via the `-remote` flag, e.g. `go test -v ./cmd/gitannex/... -remote dropbox:`. We should also port the gitannex e2e tests at some point. Issue: #7984
This commit is contained in:
committed by
Nick Craig-Wood
parent
0010090d05
commit
be33e281b3
@ -3,6 +3,8 @@ package gitannex
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/rclone/rclone/fs/fspath"
|
||||
)
|
||||
|
||||
type layoutMode string
|
||||
@ -39,8 +41,11 @@ func parseLayoutMode(mode string) layoutMode {
|
||||
type queryDirhashFunc func(msg string) (string, error)
|
||||
|
||||
func buildFsString(queryDirhash queryDirhashFunc, mode layoutMode, key, remoteName, prefix string) (string, error) {
|
||||
remoteName = strings.TrimSuffix(remoteName, ":") + ":"
|
||||
remoteString := fspath.JoinRootPath(remoteName, prefix)
|
||||
|
||||
if mode == layoutModeNodir {
|
||||
return fmt.Sprintf("%s:%s", remoteName, prefix), nil
|
||||
return remoteString, nil
|
||||
}
|
||||
|
||||
var dirhash string
|
||||
@ -59,13 +64,13 @@ func buildFsString(queryDirhash queryDirhashFunc, mode layoutMode, key, remoteNa
|
||||
|
||||
switch mode {
|
||||
case layoutModeLower:
|
||||
return fmt.Sprintf("%s:%s/%s", remoteName, prefix, dirhash), nil
|
||||
return fmt.Sprintf("%s/%s", remoteString, dirhash), nil
|
||||
case layoutModeDirectory:
|
||||
return fmt.Sprintf("%s:%s/%s%s", remoteName, prefix, dirhash, key), nil
|
||||
return fmt.Sprintf("%s/%s%s", remoteString, dirhash, key), nil
|
||||
case layoutModeMixed:
|
||||
return fmt.Sprintf("%s:%s/%s", remoteName, prefix, dirhash), nil
|
||||
return fmt.Sprintf("%s/%s", remoteString, dirhash), nil
|
||||
case layoutModeFrankencase:
|
||||
return fmt.Sprintf("%s:%s/%s", remoteName, prefix, strings.ToLower(dirhash)), nil
|
||||
return fmt.Sprintf("%s/%s", remoteString, strings.ToLower(dirhash)), nil
|
||||
default:
|
||||
panic("unreachable")
|
||||
}
|
||||
|
Reference in New Issue
Block a user