From 17fe1ffb615390ca586c0493d5ac9b2e0ed5e578 Mon Sep 17 00:00:00 2001 From: Anton Machkasov Date: Sat, 20 Feb 2021 10:22:00 +0200 Subject: [PATCH 1/2] Update goreleaser version, go version and darwin arm64 build --- .github/workflows/ci.yml | 4 +-- .goreleaser.yml | 3 -- pkg/git/utils_test.go | 61 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 pkg/git/utils_test.go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5dbc52..5eb0183 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: ci: strategy: matrix: - go-version: [1.15.x] + go-version: [1.16.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: @@ -25,7 +25,7 @@ jobs: run: go test ./... - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v2.4.1 if: success() && startsWith(github.ref, 'refs/tags/') with: version: latest diff --git a/.goreleaser.yml b/.goreleaser.yml index f1bee57..475a0c5 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -12,9 +12,6 @@ builds: goarch: - amd64 - arm64 - ignore: - - goos: darwin - goarch: arm64 archives: - replacements: darwin: Darwin diff --git a/pkg/git/utils_test.go b/pkg/git/utils_test.go new file mode 100644 index 0000000..21d2bb5 --- /dev/null +++ b/pkg/git/utils_test.go @@ -0,0 +1,61 @@ +package git + +import ( + "testing" +) + +func TestGenerateBranchName_WithoutJiraIssueKeys(t *testing.T) { + branchName, err := GenerateBranchName([]string{}, "Test string data") + + if err != nil { + t.Errorf("GenerateBranchName without Jira issue keys returned error %+v", err.Error()) + } + + expectedBranchName := "test_string__data" + if branchName != expectedBranchName { + t.Errorf("GenerateBranchName without Jira issue keys returned %+v, want %+v", branchName, expectedBranchName) + } +} + +func TestGenerateBranchName_WithSeveralJiraIssueKeys(t *testing.T) { + branchName, err := GenerateBranchName([]string{"PC-1234", "PC-345"}, "Test string data") + + if err != nil { + t.Errorf("GenerateBranchName without Jira issue keys returned error %+v", err.Error()) + } + + expectedBranchName := "PC-1234/PC-345/test_string__data" + if branchName != expectedBranchName { + t.Errorf("GenerateBranchName without Jira issue keys returned %+v, want %+v", branchName, expectedBranchName) + } +} + +func TestPrependIssueKeysToBranchName_WithoutJiraIssueKeys(t *testing.T) { + branchName, err := PrependIssueKeysToBranchName([]string{}, "test_branch_name") + + if err != nil { + t.Errorf("GenerateBranchName without Jira issue keys returned error %+v", err.Error()) + } + + expectedBranchName := "test_branch_name" + if branchName != expectedBranchName { + t.Errorf("GenerateBranchName without Jira issue keys returned %+v, want %+v", branchName, expectedBranchName) + } +} + +func TestPrependIssueKeysToBranchName_WithJiraIssueKeys(t *testing.T) { + branchName, err := PrependIssueKeysToBranchName([]string{"PC-123", "PC-345"}, "test_branch_name") + + if err != nil { + t.Errorf("PrependIssueKeysToBranchName without Jira issue keys returned error %+v", err.Error()) + } + + expectedBranchName := "PC-123/PC-345/test_branch_name" + if branchName != expectedBranchName { + t.Errorf( + "PrependIssueKeysToBranchName without Jira issue keys returned %+v, want %+v", + branchName, + expectedBranchName, + ) + } +} From 75986b601d4967c58645497bee0d0f90a691a6ff Mon Sep 17 00:00:00 2001 From: Anton Machkasov Date: Thu, 30 Dec 2021 05:55:43 +0200 Subject: [PATCH 2/2] tests: Add uts for github pkg --- pkg/git/utils_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/git/utils_test.go b/pkg/git/utils_test.go index 21d2bb5..a50213b 100644 --- a/pkg/git/utils_test.go +++ b/pkg/git/utils_test.go @@ -59,3 +59,22 @@ func TestPrependIssueKeysToBranchName_WithJiraIssueKeys(t *testing.T) { ) } } + +func TestRemoveIssueKeysFromBranchName_WithoutJiraIssueKeys(t *testing.T) { + +} + +func TestRemoveIssueKeysFromBranchName_WithJiraIssueKeys(t *testing.T) { + +} + +func TestRemoveIssueKeysFromBranchName_WithFirstJiraIssueKey(t *testing.T) { + +} +func TestRemoveIssueKeysFromBranchName_WithLastJiraIssueKey(t *testing.T) { + +} + +func TestRemoveIssueKeysFromBranchName_WithDuplicateJiraIssueKey(t *testing.T) { + +}