|
1 | | -package plugins |
| 1 | +package plugins_test |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "testing" |
| 4 | + . "github.com/praqma/git-phlow/plugins" |
5 | 5 |
|
6 | | - . "github.com/smartystreets/goconvey/convey" |
| 6 | + . "github.com/onsi/ginkgo" |
| 7 | + . "github.com/onsi/gomega" |
7 | 8 | "strconv" |
8 | 9 | ) |
9 | 10 |
|
10 | | -type testCase struct { |
11 | | - issue int |
12 | | - branchName string |
13 | | - expected string |
14 | | - casedesc string |
15 | | -} |
| 11 | +var _ = Describe("Plugin", func() { |
16 | 12 |
|
17 | | -/* Branch naming conventions |
18 | | - * - cant begin with '.' |
19 | | - * - cant have double dot '..' |
20 | | - * - cant have chars '^', '~', ':' |
21 | | - * - end with backslash / |
22 | | - * - end with ".lock" |
23 | | - * - contain \ |
24 | | - */ |
25 | | - |
26 | | -func TestBranchNameFromIssue(t *testing.T) { |
27 | | - testsToRun := [7]testCase{ |
28 | | - {issue: 12, branchName: "work on iss", expected: "12-work-on-iss", casedesc: "Test replaces whitespaces with dash '-'"}, |
29 | | - {issue: 45, branchName: "Case SENsitivity", expected: "45-case-sensitivity", casedesc: "Test converts charecters to lowercase"}, |
30 | | - {issue: 15, branchName: ".branch name", expected: "15-branch-name", casedesc: "Test removes . prefix"}, |
31 | | - {issue: 220, branchName: "^^..:~:name", expected: "220-name", casedesc: "removes ASCII control characters"}, |
32 | | - {issue: 2735, branchName: "name/", expected: "2735-name", casedesc: "test removes end / "}, |
33 | | - {issue: 234567, branchName: ".NAME.is\"dotted", expected: "234567-name-is-dotted", casedesc: "test removes backslash"}, |
34 | | - {issue: 672, branchName: "add big data blog /", expected: "672-add-big-data-blog", casedesc: "remove forward slash"}, |
| 13 | + type testCase struct { |
| 14 | + issue int |
| 15 | + branchName string |
| 16 | + expected string |
| 17 | + casedesc string |
35 | 18 | } |
36 | 19 |
|
37 | | - Convey("Running tests on 'BranchNameFromIssue'", t, func() { |
38 | | - |
39 | | - for _, currentTest := range testsToRun { |
40 | | - |
41 | | - Convey(currentTest.casedesc, func() { |
42 | | - actualName := BranchNameFromIssue(strconv.Itoa(currentTest.issue), currentTest.branchName) |
43 | | - t.Log(currentTest.branchName) |
44 | | - So(actualName, ShouldEqual, currentTest.expected) |
45 | | - }) |
| 20 | + /* Branch naming conventions |
| 21 | + * - cant begin with '.' |
| 22 | + * - cant have double dot '..' |
| 23 | + * - cant have chars '^', '~', ':' |
| 24 | + * - end with backslash / |
| 25 | + * - end with ".lock" |
| 26 | + * - contain \ |
| 27 | + */ |
| 28 | + |
| 29 | + Describe("Branch name from issue", func() { |
| 30 | + testsToRun := [7]testCase{ |
| 31 | + {issue: 12, branchName: "work on iss", expected: "12-work-on-iss", casedesc: "Test replaces whitespaces with dash '-'"}, |
| 32 | + {issue: 45, branchName: "Case SENsitivity", expected: "45-case-sensitivity", casedesc: "Test converts charecters to lowercase"}, |
| 33 | + {issue: 15, branchName: ".branch name", expected: "15-branch-name", casedesc: "Test removes . prefix"}, |
| 34 | + {issue: 220, branchName: "^^..:~:name", expected: "220-name", casedesc: "removes ASCII control characters"}, |
| 35 | + {issue: 2735, branchName: "name/", expected: "2735-name", casedesc: "test removes end / "}, |
| 36 | + {issue: 234567, branchName: ".NAME.is\"dotted", expected: "234567-name-is-dotted", casedesc: "test removes backslash"}, |
| 37 | + {issue: 672, branchName: "add big data blog /", expected: "672-add-big-data-blog", casedesc: "remove forward slash"}, |
46 | 38 | } |
47 | | - }) |
48 | | -} |
49 | 39 |
|
50 | | -func TestStringConcat(t *testing.T) { |
| 40 | + Context("Names should follow format rules", func() { |
51 | 41 |
|
52 | | - Convey("Running tests on 'effecientStringConcat' function ", t, func() { |
| 42 | + for _, currentTest := range testsToRun { |
53 | 43 |
|
54 | | - Convey("Test variable inputs get concatenated correctly", func() { |
55 | | - var expectedLong = "created 'something' new" |
56 | | - var actualLong = efficientConcatString("created '", "something", "' new") |
57 | | - So(actualLong, ShouldEqual, expectedLong) |
58 | | - }) |
| 44 | + It(currentTest.casedesc, func() { |
| 45 | + actualName := BranchNameFromIssue(strconv.Itoa(currentTest.issue), currentTest.branchName) |
59 | 46 |
|
60 | | - Convey("Test funny signs gets concatenated as well", func() { |
61 | | - var expectedShort = "j$¢‰¿≈¯¯¯" |
62 | | - var actualShort = efficientConcatString("j$¢‰¿≈", "¯¯¯") |
63 | | - So(expectedShort, ShouldEqual, actualShort) |
| 47 | + Ω(actualName).Should(Equal(currentTest.expected)) |
| 48 | + }) |
| 49 | + } |
64 | 50 | }) |
65 | 51 | }) |
66 | | -} |
67 | 52 |
|
68 | | -func TestGetIssueFromBranch(t *testing.T) { |
69 | | - Convey("Running tests on 'GetIssuesFromBranch'", t, func() { |
70 | | - |
71 | | - Convey("GetIssueSFromBranch should return 1", func() { |
72 | | - |
73 | | - i := IssueFromBranchName("39-enable---Add-sign-in-function") |
74 | | - So(i, ShouldEqual, "39") |
75 | | - }) |
76 | | - }) |
77 | | -} |
| 53 | +}) |
0 commit comments