@@ -7,124 +7,65 @@ import (
77
88var _ = Describe ("Branch" , func () {
99
10- Describe ("branch" , func () {
11- gitCmdOut := `
12- 192-move-git-commands-to-new-configuration
13- delivered/164-detect-github-and-bitbucket-from-config
14- * master
15- remotes/origin/HEAD -> origin/master
16- remotes/origin/master
17- remotes/origin/version`
10+ Describe ("AsList" , func () {
1811
19- It ("Something" , func () {
20- osExec = func (command string , argv ... string ) (string , error ) {
21- return gitCmdOut , nil
22- }
12+ It ("should return a list of branches" , func () {
13+ info := AsList (gitBranchOut )
14+ Ω (info .List ).Should (HaveLen (11 ))
15+ })
16+
17+ It ("should return nothing" , func () {
18+ info := AsList ("læadsjklfjaskldjsakldjaskld" )
19+ Ω (info .List ).Should (HaveLen (1 ))
20+ })
2321
24- info , _ := Branch ()
22+ It ("should return the current branch " , func () {
23+ info := AsList (gitBranchOut )
2524 Ω (info .Current ).Should (Equal ("master" ))
25+ })
26+
27+ It ("should not return master" , func () {
28+ info := AsList ("læadsjklfjaskldjsakldjaskld" )
29+ Ω (info .Current ).Should (Equal ("" ))
30+ })
31+
32+ })
2633
34+ Describe ("Delivered" , func () {
35+
36+ It ("should return delivered branch" , func () {
37+ info := AsList (gitBranchOut )
38+ local , remote := Delivered (info , "origin" )
39+ Ω (local ).Should (HaveLen (2 ))
40+ Ω (remote ).Should (HaveLen (1 ))
2741 })
42+
2843 })
2944
30- //BeforeEach(func() {
31- //
32- // //Runs before each "It" block
33- // testfixture.CreateTestRepositoryNoLog(false)
34- //})
35- //
36- //Describe("Branch Function execution", func() {
37- //
38- // It("should return a list of branches", func() {
39- // info, err := Branch()
40- // Ω(len(info.List)).Should(Equal(11))
41- // Ω(err).Should(BeNil())
42- // })
43- //
44- // It("branch should return Current branch", func() {
45- // info, err := Branch()
46- // Ω(info.Current).Should(Equal("master"))
47- // Ω(err).Should(BeNil())
48- // })
49- //
50- //})
51- //
52- //Describe("Delete Branch Function", func() {
53- //
54- // It("should delete local branch and return message", func() {
55- // output, err := BranchDelete("delivered/1-issue-branch", "", false, false)
56- // info, _ := Branch()
57- //
58- // Ω(err).Should(BeNil())
59- // Ω(output).ShouldNot(BeEmpty())
60- // Ω(info.List).Should(HaveLen(10))
61- // })
62- //
63- // It("should delete remote branch and return message", func() {
64- // _, err1 := BranchDelete("delivered/24-issue-branch", "origin", true, false)
65- // _, err2 := BranchDelete("delivered/42-issue-branch", "origin", true, false)
66- // info, _ := Branch()
67- //
68- // Ω(err1).Should(BeNil())
69- // Ω(err2).Should(BeNil())
70- //
71- // Ω(info.List).Should(HaveLen(9))
72- // })
73- //
74- //})
75- //
76- //Describe("Executing BranchDelivered", func() {
77- // It("should return lists of delivered branches", func() {
78- // locals, remotes := BranchDelivered("origin")
79- // Ω(locals).Should(HaveLen(1))
80- // Ω(remotes).Should(HaveLen(2))
81- // Ω(remotes).Should(ContainElement("delivered/24-issue-branch"))
82- // })
83- //
84- //})
85- //
86- //Describe("Running BranchDelivered", func() {
87- //
88- // It("should return list of ready branches", func() {
89- // remotes := BranchReady("origin", "ready/")
90- //
91- // Ω(remotes).Should(HaveLen(2))
92- // Ω(remotes).Should(ContainElement("origin/ready/99-issue-branch"))
93- // })
94- //
95- //})
96- //
97- //Describe("Running tests on 'BranchTime' function", func() {
98- //
99- // It("Should get unix timestamp", func() {
100- // output, err := BranchTime("origin/ready/99-issue-branch")
101- // Ω(err).Should(BeNil())
102- // Ω(output).Should(BeNumerically(">", 100000))
103- //
104- // })
105- //
106- // It("Should fail geting unix timestamp", func() {
107- // output, err := BranchTime("bluarh.. not a branch")
108- // Ω(err).ShouldNot(BeNil())
109- // Ω(output).Should(Equal(-1))
110- // })
111- //
112- //})
113- //
114- //Describe("Executing BranchRemote", func() {
115- //
116- // It("should return origin/master", func() {
117- // output, err := branchRemote()
118- //
119- // Ω(err).Should(BeNil())
120- // Ω(output).Should(Equal("origin/master"))
121- //
122- // })
123- //
124- //})
125- //
126- //AfterEach(func() {
127- // testfixture.RemoveTestRepositoryNoLog()
128- //})
45+ Describe ("Ready" , func () {
46+
47+ It ("should return list of ready branches" , func () {
48+ info := AsList (gitBranchOut )
49+ ready := Ready (info , "origin" , "ready" )
50+
51+ Ω (ready ).Should (HaveLen (1 ))
52+ Ω (ready ).Should (ContainElement ("origin/ready/31-add-documentation-for-docker-compose" ))
53+ })
54+
55+ })
12956
13057})
58+
59+ var gitBranchOut = `
60+ 23-add-impl-for-postgres
61+ 24-isolate-rest-for-scalability
62+ 31-add-documentation-for-docker-compose
63+ delivered/30-change-docker-config-to-k8
64+ delivered/31-add-documentation-for-docker-compose
65+ * master
66+ remotes/origin/HEAD -> origin/master
67+ remotes/origin/master
68+ remotes/origin/ready/31-add-documentation-for-docker-compose
69+ remotes/origin/version
70+ remotes/origin/delivered/31-add-documentation-for-docker-compose
71+ `
0 commit comments