git-lfs/fs/fs_test.go

45 lines
951 B
Go
Raw Normal View History

2018-06-26 22:57:05 +00:00
package fs
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
2018-06-26 22:57:05 +00:00
func TestDecodeNone(t *testing.T) {
2018-06-13 14:56:46 +00:00
evaluate(t, "A:\\some\\regular\\windows\\path", "A:\\some\\regular\\windows\\path")
2018-06-26 22:57:05 +00:00
}
func TestDecodeSingle(t *testing.T) {
2018-06-13 14:56:46 +00:00
evaluate(t, "A:\\bl\\303\\204\\file.txt", "A:\\blÄ\\file.txt")
2018-06-26 22:57:05 +00:00
}
func TestDecodeMultiple(t *testing.T) {
2018-06-13 14:56:46 +00:00
evaluate(t, "A:\\fo\\130\\file\\303\\261.txt", "A:\\fo\130\\file\303\261.txt")
2018-06-26 22:57:05 +00:00
}
func evaluate(t *testing.T, input string, expected string) {
2018-06-13 14:56:46 +00:00
fs := Filesystem{}
2018-06-26 22:57:05 +00:00
output := fs.DecodePathname(input)
2018-06-13 14:56:46 +00:00
2018-06-26 22:57:05 +00:00
if output != expected {
2018-06-13 14:56:46 +00:00
t.Errorf("Expecting same path, got: %s, want: %s.", output, expected)
}
}
func TestRepositoryPermissions(t *testing.T) {
m := map[os.FileMode]os.FileMode{
0777: 0666,
0755: 0644,
0700: 0600,
}
for k, v := range m {
fs := Filesystem{repoPerms: v}
assert.Equal(t, k, fs.RepositoryPermissions(true))
assert.Equal(t, v, fs.RepositoryPermissions(false))
}
}