-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from macanton/add-unit-tests-for-github-utils
Add unit tests for GitHub utils
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
||
} |