aboutsummaryrefslogtreecommitdiff
path: root/lib/git/git_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-02 00:40:21 +0700
committerShulhan <ms@kilabit.info>2026-01-06 14:56:07 +0700
commit18be916ab6f8911fd23d8f0a91f5a26f3c07f636 (patch)
treeac6d36924c851e81cd539c4b7b3ee0d307c5df74 /lib/git/git_test.go
parent988ff4596d6fb600d0c94aeed41b5b17f1677032 (diff)
downloadpakakeh.go-18be916ab6f8911fd23d8f0a91f5a26f3c07f636.tar.xz
lib/git: add Git type with method IsIgnored
The Git type is for working with single git repository. The [Git.IsIgnored] method is to check if the `path` is ignored by git. This is processed by matching it with all of the pattern in the ".gitignore" file from the path directory and its parent until the root of Git repository.
Diffstat (limited to 'lib/git/git_test.go')
-rw-r--r--lib/git/git_test.go26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/git/git_test.go b/lib/git/git_test.go
index bcc63a95..70a9ccca 100644
--- a/lib/git/git_test.go
+++ b/lib/git/git_test.go
@@ -1,6 +1,5 @@
-// Copyright 2018, Shulhan <ms@kilabit.info>. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
+// SPDX-License-Identifier: BSD-3-Clause
+// SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info>
package git
@@ -44,6 +43,27 @@ func TestMain(m *testing.M) {
os.Exit(s)
}
+func TestNew(t *testing.T) {
+ type testCase struct {
+ dir string
+ expError string
+ }
+ var listCase = []testCase{{
+ dir: `testdata/New/fail_no_git`,
+ expError: `New: "testdata/New/fail_no_git" is not a git repository`,
+ }, {
+ dir: `testdata/New/fail_not_dir`,
+ expError: `New: "testdata/New/fail_not_dir" is not a git repository`,
+ }}
+
+ var err error
+ var tcase testCase
+ for _, tcase = range listCase {
+ _, err = New(tcase.dir)
+ test.Assert(t, `error`, tcase.expError, err.Error())
+ }
+}
+
func TestClone(t *testing.T) {
cases := []struct {
desc, dest, expErr, expStderr, expStdout string