File: fs_test.go

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (44 lines) | stat: -rw-r--r-- 951 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package fs

import (
	"os"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDecodeNone(t *testing.T) {
	evaluate(t, "A:\\some\\regular\\windows\\path", "A:\\some\\regular\\windows\\path")
}

func TestDecodeSingle(t *testing.T) {
	evaluate(t, "A:\\bl\\303\\204\\file.txt", "A:\\blÄ\\file.txt")
}

func TestDecodeMultiple(t *testing.T) {
	evaluate(t, "A:\\fo\\130\\file\\303\\261.txt", "A:\\fo\130\\file\303\261.txt")
}

func evaluate(t *testing.T, input string, expected string) {

	fs := Filesystem{}
	output := fs.DecodePathname(input)

	if output != expected {
		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))
	}
}