diff options
author | Alec Lanter <kintar1900@gmail.com> | 2023-01-23 10:10:11 -0600 |
---|---|---|
committer | Alec Lanter <kintar1900@gmail.com> | 2023-01-23 10:10:11 -0600 |
commit | 70f405e7b15148ba0c3de89355b7dd5cb3befa60 (patch) | |
tree | 150592e9dff33f44bc3e0f15ceca0b85cd1a9e26 /repository/gogit_test.go | |
parent | e97df9c8102c92701489cb2693294064f1488b4b (diff) | |
download | git-bug-70f405e7b15148ba0c3de89355b7dd5cb3befa60.tar.gz git-bug-70f405e7b15148ba0c3de89355b7dd5cb3befa60.zip |
test: resolve changes for PR #1004, add unit test, fix issue uncovered by unit test
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) +} |