@ -12,7 +12,7 @@ import (
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/setting"
)
)
func Test_isGitOrLFSPath ( t * testing . T ) {
func Test_isGitRaw OrLFSPath ( t * testing . T ) {
tests := [ ] struct {
tests := [ ] struct {
path string
path string
@ -63,6 +63,10 @@ func Test_isGitOrLFSPath(t *testing.T) {
"/owner/repo/objects/pack/pack-0123456789abcdef0123456789abcdef0123456.idx" ,
"/owner/repo/objects/pack/pack-0123456789abcdef0123456789abcdef0123456.idx" ,
true ,
true ,
} ,
} ,
{
"/owner/repo/raw/branch/foo/fanaso" ,
true ,
} ,
{
{
"/owner/repo/stars" ,
"/owner/repo/stars" ,
false ,
false ,
@ -98,11 +102,11 @@ func Test_isGitOrLFSPath(t *testing.T) {
t . Run ( tt . path , func ( t * testing . T ) {
t . Run ( tt . path , func ( t * testing . T ) {
req , _ := http . NewRequest ( "POST" , "http://localhost" + tt . path , nil )
req , _ := http . NewRequest ( "POST" , "http://localhost" + tt . path , nil )
setting . LFS . StartServer = false
setting . LFS . StartServer = false
if got := isGitOrLFSPath ( req ) ; got != tt . want {
if got := isGitRaw OrLFSPath ( req ) ; got != tt . want {
t . Errorf ( "isGitOrLFSPath() = %v, want %v" , got , tt . want )
t . Errorf ( "isGitOrLFSPath() = %v, want %v" , got , tt . want )
}
}
setting . LFS . StartServer = true
setting . LFS . StartServer = true
if got := isGitOrLFSPath ( req ) ; got != tt . want {
if got := isGitRaw OrLFSPath ( req ) ; got != tt . want {
t . Errorf ( "isGitOrLFSPath() = %v, want %v" , got , tt . want )
t . Errorf ( "isGitOrLFSPath() = %v, want %v" , got , tt . want )
}
}
} )
} )
@ -111,11 +115,11 @@ func Test_isGitOrLFSPath(t *testing.T) {
t . Run ( tt , func ( t * testing . T ) {
t . Run ( tt , func ( t * testing . T ) {
req , _ := http . NewRequest ( "POST" , tt , nil )
req , _ := http . NewRequest ( "POST" , tt , nil )
setting . LFS . StartServer = false
setting . LFS . StartServer = false
if got := isGitOrLFSPath ( req ) ; got != setting . LFS . StartServer {
if got := isGitRaw OrLFSPath ( req ) ; got != setting . LFS . StartServer {
t . Errorf ( "isGitOrLFSPath(%q) = %v, want %v, %v" , tt , got , setting . LFS . StartServer , gitPathRe . MatchString ( tt ) )
t . Errorf ( "isGitOrLFSPath(%q) = %v, want %v, %v" , tt , got , setting . LFS . StartServer , gitRaw PathRe . MatchString ( tt ) )
}
}
setting . LFS . StartServer = true
setting . LFS . StartServer = true
if got := isGitOrLFSPath ( req ) ; got != setting . LFS . StartServer {
if got := isGitRaw OrLFSPath ( req ) ; got != setting . LFS . StartServer {
t . Errorf ( "isGitOrLFSPath(%q) = %v, want %v" , tt , got , setting . LFS . StartServer )
t . Errorf ( "isGitOrLFSPath(%q) = %v, want %v" , tt , got , setting . LFS . StartServer )
}
}
} )
} )