aboutsummaryrefslogtreecommitdiff
path: root/lib/git/git_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-02-09 15:42:29 +0700
committerShulhan <ms@kilabit.info>2026-02-09 15:42:29 +0700
commit1e9c2f8044c842b8f9287fa50e1072406aa9fa40 (patch)
treea0a226afa332e27257c04adeaad0718c933a2c58 /lib/git/git_test.go
parent9cc27f817a1850692451513732024d18007c4868 (diff)
downloadpakakeh.go-1e9c2f8044c842b8f9287fa50e1072406aa9fa40.tar.xz
lib/git: fix tests due to missing .git directory
In lib/git, we have test data "testdata/Equal" and "testdata/IsIgnored" that require the directory named ".git". Somehow those directory is missing from previous commit, which cause the test failed when run in new clone. After we inspect it, git does not allow adding a file under directory named ".git" (to include it inside the commit), so to fix the test we need to create the ".git" directory manually before running the tests.
Diffstat (limited to 'lib/git/git_test.go')
-rw-r--r--lib/git/git_test.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/git/git_test.go b/lib/git/git_test.go
index 7462ef1d..92daa143 100644
--- a/lib/git/git_test.go
+++ b/lib/git/git_test.go
@@ -148,8 +148,14 @@ func TestGit_Equal(t *testing.T) {
v: nilgit,
}}
+ // We cannot add and commit file under .git directory, so we must
+ // create the directory manually here.
+ err := os.MkdirAll(`testdata/Equal/.git`, 0755)
+ if err != nil {
+ t.Fatal(err)
+ }
+
var agit *Git
- var err error
agit, err = New(`testdata/Equal`)
if err != nil {
t.Fatal(err)
@@ -164,6 +170,13 @@ func TestGit_Equal(t *testing.T) {
}
func TestGit_IsIgnored(t *testing.T) {
+ // We cannot add and commit file under .git directory, so we must
+ // create the directory manually here.
+ err := os.MkdirAll(`testdata/IsIgnored/.git`, 0755)
+ if err != nil {
+ t.Fatal(err)
+ }
+
agit, err := New(`testdata/IsIgnored/`)
if err != nil {
t.Fatal(err)