Skip to content

Commit fd55f4c

Browse files
Assert IndividualBuildConfig values are defined in the jenkins-helper (#727)
* Correctly assert IndividualBuildConfig values are defined in the jenkins-helper Signed-off-by: Andrew Leonard <[email protected]> * Correctly assert IndividualBuildConfig values are defined in the jenkins-helper Signed-off-by: Andrew Leonard <[email protected]> * Correctly assert IndividualBuildConfig values are defined in the jenkins-helper Signed-off-by: Andrew Leonard <[email protected]> --------- Signed-off-by: Andrew Leonard <[email protected]>
1 parent 2dae8fa commit fd55f4c

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

pipelines/src/test/groovy/IndividualBuildConfigTest.groovy

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ import groovy.json.JsonOutput
33
import org.junit.jupiter.api.Assertions
44
import org.junit.jupiter.api.Test
55

6+
/**
7+
* Tests for IndividualBuildConfig
8+
*/
69
class IndividualBuildConfigTest {
710

811
@Test
912
void serializationTransfersDataCorrectly() {
10-
def config = new IndividualBuildConfig([
13+
def configMap = [
1114
ARCHITECTURE : 'a',
1215
TARGET_OS : 'b',
1316
VARIANT : 'c',
1417
JAVA_TO_BUILD : 'd',
15-
TEST_LIST : 'e',
16-
DYNAMIC_LIST : 'e',
17-
NUM_MACHINES : 'e',
18+
TEST_LIST : ['e'],
19+
DYNAMIC_LIST : ['e'],
20+
NUM_MACHINES : ['e'],
1821
SCM_REF : 'f',
1922
BUILD_REF : 'w',
2023
CI_REF : 'x',
@@ -47,18 +50,24 @@ class IndividualBuildConfigTest {
4750
ENABLE_SIGNER : true,
4851
CLEAN_WORKSPACE : false,
4952
CLEAN_WORKSPACE_AFTER : false,
50-
CLEAN_WORKSPACE_BUILD_OUTPUT_ONLY_AFTER : false
51-
])
53+
CLEAN_WORKSPACE_BUILD_OUTPUT_ONLY_AFTER : false,
54+
ENABLE_REPRODUCIBLE_COMPARE : false,
55+
ENABLE_TESTDYNAMICPARALLEL : false
56+
]
57+
def testConfig = new IndividualBuildConfig(configMap)
5258

53-
def json = config.toJson()
59+
// Serialize and then re-constitute
60+
def json = testConfig.toJson()
5461
def parsedConfig = new IndividualBuildConfig(json)
5562

63+
// Assert all values set
5664
parsedConfig.toRawMap()
5765
.each { val ->
5866
Assertions.assertNotNull(val.value, "${val.key} is null")
5967
}
6068

61-
Assertions.assertEquals(JsonOutput.toJson(config), JsonOutput.toJson(parsedConfig))
69+
// Assert serialization round trip matches initial configMap
70+
Assertions.assertEquals(configMap, parsedConfig.toRawMap())
6271
}
6372

6473
@Test

0 commit comments

Comments
 (0)