grim/hgkeeper

Parents 37b0575030fb
Children 876d62398b99
Add some additional used tests for find hgrcs for repo and fix a bug
--- a/hg/hgrc.go Fri Nov 13 20:56:05 2020 -0600
+++ b/hg/hgrc.go Fri Nov 13 21:42:29 2020 -0600
@@ -40,7 +40,7 @@
for {
ret = append(ret, filepath.Join(adminPath, "config", repoName, "hgrc"))
- if repoName == "." {
+ if repoName == "." || repoName == "" {
break
}
repoName = filepath.Dir(repoName)
--- a/hg/hgrc_test.go Fri Nov 13 20:56:05 2020 -0600
+++ b/hg/hgrc_test.go Fri Nov 13 21:42:29 2020 -0600
@@ -6,7 +6,7 @@
"github.com/stretchr/testify/assert"
)
-func TestFindHgrcsForRepo(t *testing.T) {
+func TestFindHgrcsForRepoSimple(t *testing.T) {
actual := findHgrcsForRepo("grim/hgkeeper")
expected := []string{
"config/hgrc",
@@ -16,3 +16,21 @@
assert.Equal(t, expected, actual)
}
+
+func TestFindHgrcsForRepoEmpty(t *testing.T) {
+ actual := findHgrcsForRepo("")
+ expected := []string{
+ "config/hgrc",
+ }
+
+ assert.Equal(t, expected, actual)
+}
+
+func TestFindHgrcsForRepoDot(t *testing.T) {
+ actual := findHgrcsForRepo(".")
+ expected := []string{
+ "config/hgrc",
+ }
+
+ assert.Equal(t, expected, actual)
+}