Skip to content

Commit

Permalink
Merge pull request #17 from macanton/add-unit-tests-for-github-utils
Browse files Browse the repository at this point in the history
Add unit tests for GitHub utils
  • Loading branch information
macanton authored Jan 24, 2022
2 parents 942fb67 + 75986b6 commit 26ac439
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions pkg/git/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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,
)
}
}

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) {

}

0 comments on commit 26ac439

Please sign in to comment.