11package com.cloudogu.ces.cesbuildlib
22
33import org.junit.Test
4+ import org.junit.jupiter.api.DisplayName
45
56import static org.assertj.core.api.Assertions.assertThat
67
@@ -39,7 +40,7 @@ class MakefileTest {
3940
4041 Makefile makefile = new Makefile (scriptMock)
4142
42- def result = makefile. getDevelopBranchName ()
43+ def result = makefile. determineGitFlowDevelopBranch ()
4344
4445 assertThat (scriptMock. allActualArgs[0 ]). isEqualTo(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString())
4546 assertThat (result). isEqualTo(" 4.2.2/develop" )
@@ -52,7 +53,7 @@ class MakefileTest {
5253
5354 Makefile makefile = new Makefile (scriptMock)
5455
55- def result = makefile. getMainBranchName ()
56+ def result = makefile. determineGitFlowMainBranch ()
5657
5758 assertThat (scriptMock. allActualArgs[0 ]). isEqualTo(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString())
5859 assertThat (result). isEqualTo(" 4.2.2/main" )
@@ -65,7 +66,7 @@ class MakefileTest {
6566
6667 Makefile makefile = new Makefile (scriptMock)
6768
68- def result = makefile. getDevelopBranchName ()
69+ def result = makefile. determineGitFlowDevelopBranch ()
6970
7071 assertThat (scriptMock. allActualArgs[0 ]). isEqualTo(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString())
7172 assertThat (result). isEqualTo(" develop" )
@@ -78,9 +79,37 @@ class MakefileTest {
7879
7980 Makefile makefile = new Makefile (scriptMock)
8081
81- def result = makefile. getMainBranchName ()
82+ def result = makefile. determineGitFlowMainBranch ()
8283
8384 assertThat (scriptMock. allActualArgs[0 ]). isEqualTo(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString())
8485 assertThat (result). isEqualTo(" main" )
8586 }
87+
88+ @Test
89+ @DisplayName (" should replace master with main if BASE_VERSION is used and the default branch is master" )
90+ void shouldReplaceMasterWithMain () {
91+ def scriptMock = new ScriptMock ()
92+ scriptMock. expectedShRetValueForScript. put(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString(), " 4.5" . toString())
93+
94+ Makefile makefile = new Makefile (scriptMock)
95+
96+ def result = makefile. determineGitFlowMainBranch(" master" )
97+
98+ assertThat (scriptMock. allActualArgs[0 ]). isEqualTo(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString())
99+ assertThat (result). isEqualTo(" 4.5/main" )
100+ }
101+
102+ @Test
103+ @DisplayName (" should use default branch if BASE_VERSION is not used" )
104+ void shouldUseDefaultBranch () {
105+ def scriptMock = new ScriptMock ()
106+ scriptMock. expectedShRetValueForScript. put(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString(), " " . toString())
107+
108+ Makefile makefile = new Makefile (scriptMock)
109+
110+ def result = makefile. determineGitFlowMainBranch(" master" )
111+
112+ assertThat (scriptMock. allActualArgs[0 ]). isEqualTo(' grep -e "^BASE_VERSION=" Makefile | sed "s/BASE_VERSION=//g"' . toString())
113+ assertThat (result). isEqualTo(" master" )
114+ }
86115}
0 commit comments