Debian Codegraph @

fs/fs_test.go

raw symbols SCIP
1 package fs
2
3 import (
4 "os"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 )
9
10 func TestDecodeNone(t *testing.T) {
11 evaluate(t, "A:\\some\\regular\\windows\\path", "A:\\some\\regular\\windows\\path")
12 }
13
14 func TestDecodeSingle(t *testing.T) {
15 evaluate(t, "A:\\bl\\303\\204\\file.txt", "A:\\blÄ\\file.txt")
16 }
17
18 func TestDecodeMultiple(t *testing.T) {
19 evaluate(t, "A:\\fo\\130\\file\\303\\261.txt", "A:\\fo\130\\file\303\261.txt")
20 }
21
22 func evaluate(t *testing.T, input string, expected string) {
23
24 fs := Filesystem{}
25 output := fs.DecodePathname(input)
26
27 if output != expected {
28 t.Errorf("Expecting same path, got: %s, want: %s.", output, expected)
29 }
30
31 }
32
33 func TestRepositoryPermissions(t *testing.T) {
34 m := map[os.FileMode]os.FileMode{
35 0777: 0666,
36 0755: 0644,
37 0700: 0600,
38 }
39 for k, v := range m {
40 fs := Filesystem{repoPerms: v}
41 assert.Equal(t, k, fs.RepositoryPermissions(true))
42 assert.Equal(t, v, fs.RepositoryPermissions(false))
43 }
44 }