aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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 ./...