This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / gitutil / readme_test.go
1.2 kB 48 lines
1package gitutil 2 3import "testing" 4 5func TestIsReadmeFile(t *testing.T) { 6 const ( 7 fileMode = "100644" 8 execMode = "100755" 9 dirMode = "040000" 10 ) 11 12 cases := []struct { 13 name string 14 mode string 15 want bool 16 }{ 17 {"README.md", fileMode, true}, 18 {"ReadMe.MD", fileMode, true}, 19 {"readme", fileMode, true}, 20 {"README", execMode, true}, 21 22 // regression: a directory named "readme" must not be picked up 23 // as the README blob; tree handlers used to fetch it and 503. 24 {"readme", dirMode, false}, 25 {"README.md", dirMode, false}, 26 27 // readme is matched by convention, not by renderable format; 28 // unsupported markup falls through to plaintext in GetFormat. 29 {"README.rst", fileMode, true}, 30 {"README.foo", fileMode, true}, 31 32 {"README.Music.md", fileMode, false}, 33 {"readme-old", fileMode, false}, 34 {"readme_legacy", fileMode, false}, 35 {"notreadme.md", fileMode, false}, 36 {"READMEISH", fileMode, false}, 37 {"README.md", "", false}, 38 {"README.md", "120000", false}, // symlink 39 } 40 41 for _, c := range cases { 42 t.Run(c.name+"/"+c.mode, func(t *testing.T) { 43 if got := IsReadmeFile(c.name, c.mode); got != c.want { 44 t.Errorf("IsReadmeFile(%q, %q) = %v, want %v", c.name, c.mode, got, c.want) 45 } 46 }) 47 } 48}