aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-11-27 02:48:26 +0900
committernsfisis <nsfisis@gmail.com>2025-11-27 02:48:26 +0900
commitb61815b7499e7286e88d7de9fe667af08ab66f55 (patch)
treefc150dcadab9cbee20cab69762d9f3399ed1eeae
parent4a3bb02d0dbcdcd9222b50d6c18117db75d65666 (diff)
downloadgit-helpers-b61815b7499e7286e88d7de9fe667af08ab66f55.tar.gz
git-helpers-b61815b7499e7286e88d7de9fe667af08ab66f55.tar.zst
git-helpers-b61815b7499e7286e88d7de9fe667af08ab66f55.zip
add tests
-rw-r--r--cmd/git-extract-issue/main_test.go35
-rw-r--r--justfile5
2 files changed, 40 insertions, 0 deletions
diff --git a/cmd/git-extract-issue/main_test.go b/cmd/git-extract-issue/main_test.go
new file mode 100644
index 0000000..dbf88c5
--- /dev/null
+++ b/cmd/git-extract-issue/main_test.go
@@ -0,0 +1,35 @@
+package main
+
+import "testing"
+
+func TestExtractIssueNumberFromBranchName(t *testing.T) {
+ tests := []struct {
+ name string
+ branchName string
+ expected string
+ }{
+ {"numeric only", "123", "#123"},
+ {"numeric with suffix", "123-suffix", "#123"},
+
+ {"feature prefix", "feature/123", "#123"},
+ {"feature prefix with suffix", "feature/123-suffix", "#123"},
+
+ {"project prefix", "feature/prefix-123", "prefix-123"},
+ {"project prefix with suffix", "feature/prefix-123-suffix", "prefix-123"},
+
+ {"bugfix prefix", "bugfix/123", "#123"},
+ {"hotfix prefix", "hotfix/456-fix", "#456"},
+
+ {"no number", "feature/no-number", ""},
+ {"empty string", "", ""},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ actual := extractIssueNumberFromBranchName(tt.branchName)
+ if actual != tt.expected {
+ t.Errorf("extractIssueNumberFromBranchName(%q) = %q, expected %q", tt.branchName, actual, tt.expected)
+ }
+ })
+ }
+}
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..a14db65
--- /dev/null
+++ b/justfile
@@ -0,0 +1,5 @@
+build:
+ go build ./...
+
+test:
+ go test ./...