gogs/internal/db/repo_editor_test.go
Unknwon 01c8df01ec
internal: move packages under this directory (#5836)
* Rename pkg -> internal

* Rename routes -> route

* Move route -> internal/route

* Rename models -> db

* Move db -> internal/db

* Fix route2 -> route

* Move cmd -> internal/cmd

* Bump version
2019-10-24 01:51:46 -07:00

35 lines
839 B
Go

// Copyright 2018 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package db
import (
"os"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func Test_isRepositoryGitPath(t *testing.T) {
Convey("Check if path is or resides inside '.git'", t, func() {
sep := string(os.PathSeparator)
testCases := []struct {
path string
expect bool
}{
{"." + sep + ".git", true},
{"." + sep + ".git" + sep + "", true},
{"." + sep + ".git" + sep + "hooks" + sep + "pre-commit", true},
{".git" + sep + "hooks", true},
{"dir" + sep + ".git", true},
{".gitignore", false},
{"dir" + sep + ".gitkeep", false},
}
for _, tc := range testCases {
So(isRepositoryGitPath(tc.path), ShouldEqual, tc.expect)
}
})
}