diff options
Diffstat (limited to 'repository/gogit_test.go')
-rw-r--r-- | repository/gogit_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/repository/gogit_test.go b/repository/gogit_test.go index 02bd42fd..2bec97a5 100644 --- a/repository/gogit_test.go +++ b/repository/gogit_test.go @@ -1,6 +1,7 @@ package repository import ( + "os" "path" "path/filepath" "testing" @@ -81,3 +82,21 @@ func TestGoGitRepo_Indexes(t *testing.T) { require.NoError(t, err) require.NotZero(t, indexA) } + +func TestGoGit_DetectsSubmodules(t *testing.T) { + expectedPath := "../foo/bar" + submoduleData := "gitdir: " + expectedPath + d := t.TempDir() + if f, err := os.Create(filepath.Join(d, ".git")); err != nil { + t.Fatal("could not create necessary temp file:", err) + } else { + t.Log(f.Name()) + if _, err := f.Write([]byte(submoduleData)); err != nil { + t.Fatal("could not write necessary data to temp file:", err) + } + _ = f.Close() + } + result, err := detectGitPath(d) + assert.Empty(t, err) + assert.Equal(t, expectedPath, result) +} |